TypeScript on NodeRun
About This Space
An example of creating server side typescript modules.
Last updated on March 24, 2020
Public Permissions: View Open/Fork Run Comment
Server Side Typescript
You can write modules using typescript with just a couple requirements.
- Implement your logic within the class constructor
- This allows for the module to be "callable" from other modules.
- Define global variables outside of the class
- Within Profound.js, you strongly define variables using the pjs.define() API, which do not create typescript variables.
- Typescript needs all variables to be defined in order to be compiled
- When calling a typescript module, you must include the ".ts" file extension on the pjs.call() API.
app.js
This is a simple Profound.js module calling a server side typescript module.
- Notice the only difference is that you must include the file extension.
hello.ts
This is a simple Hello World module. This is a rewrite of the file app.js from the "Rich Display Hello World" template.
- Notice the constructor and global variables
webservice.ts
Here is a webservice example in Typescript
- Again, notice the constructor and global variables
Additional Documentation
Server-side Typescript - Includes examples of importing and using other/external TS modules.
Be the first to comment:
Comments