Event-driven I/O server-side JavaScript environment https://nodejs.org/en/download/
Package manager
npm install npm -g
TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. Any browser. Any host. Any OS. Open Source.
npm install -g typescript
Adopted
Use it in all new projects instead of JavaScript.
TypeScript comes to you with modularity
, correctness
, refactoring
, intellisense
, support of future EcmaScripts
JavaScript
1: 2: 3: |
|
TypeScript
1: 2: |
|
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: |
|
1: 2: 3: 4: 5: 6: |
|
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: |
|
VS Code includes support for debugging, embedded Git control, syntax highlighting, intelligent code completion, snippets, and code refactoring. It is also customizable, so users can change the editor's theme, keyboard shortcuts, and preferences.
The .vscode/settings.json
file allows to configure:
tsconfig.json
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: |
|
typings.json
1: 2: 3: 4: 5: 6: |
|
tsconfig.json
1: 2: 3: 4: 5: |
|
package.json
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: |
|
npm install
package.json
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: |
|
npm start
app/app.component.ts
1: 2: 3: 4: 5: 6: 7: |
|
app/main.ts
1: 2: 3: 4: |
|
Platform specific bootstrap Browser, Apache Cordova, NativeScript or server-side rendering.
index.html
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: |
|
Http.get
returns Observable<Response>
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: |
|
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: |
|
Binding
1: 2: 3: |
|
1: 2: 3: 4: 5: 6: |
|
CORS
Adding the necessary HTTP response headers Access-Control-Allow-Headers
,
Access-Control-Allow-Methods
and Access-Control-Allow-Origin
at IIS level.
1: 2: 3: 4: 5: 6: 7: 8: 9: |
|
In a SharePoint context, you can add those headers for a given web app using the IIS console
Develop a HTTP module to work around the authentication problem regarding the preflight requests
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: |
|
Reverse Proxy
OnBeforeResponse
function and add the following1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: |
|