You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-48
Original file line number
Diff line number
Diff line change
@@ -7,12 +7,11 @@ TypeScript loader for SystemJS
7
7
8
8
## Overview ##
9
9
10
-
A plugin for [SystemJS](https://github.com/systemjs/systemjs) which enables you to ```System.import``` TypeScript files directly. The files are compiled in the browser and compilation errors written to the console.
10
+
A plugin for [SystemJS](https://github.com/systemjs/systemjs) which enables you to ```System.import``` TypeScript files directly. The files are transpiled in the browser and compilation errors written to the console.
11
11
12
-
Starting with JSPM 0.17.0 (currently in beta) this plugin will be the officially supported mechanism for transpiling TypeScript. It provides the ability to type-check files while loading them, which is not currently possible with the built-in SystemJS TypeScript transpiler.
12
+
Starting with JSPM 0.17.0 (currently in beta) this plugin will be the officially supported mechanism for transpiling TypeScript. It provides the ability to transpile TypeScript and ES2015+ files on the fly when then are loaded by SystemJS.
13
13
14
-
plugin-typescript uses TypeScript ^2.1.0
15
-
For TypeScript 2.0.x use plugin-typescript 5.2.9
14
+
For SystemJS @0.19 use plugin-typescript 5.3.3
16
15
For TypeScript 1.8.1 use plugin-typescript 4.0.16
17
16
For TypeScript 1.7.5 and below use plugin-typescript 2.x.x
18
17
@@ -70,13 +69,11 @@ System.config({
70
69
});
71
70
```
72
71
73
-
This will tell SystemJS to transpile all modules (.js and .ts) using plugin-typescript.
74
-
75
-
#### Plus: for full type-checking add ```packages``` configuration ####
72
+
This will tell SystemJS to transpile all modules (.js and .ts) using plugin-typescript. It is also possible to configure plugin-typescript to load specific files, using ```packages``` configuration
76
73
77
74
```js
78
75
System.config({
79
-
transpiler:"ts",
76
+
transpiler:"babel",
80
77
packages: {
81
78
"src": {
82
79
"defaultExtension":"ts",
@@ -103,56 +100,35 @@ System.config({
103
100
typescriptOptions: {
104
101
module:"system",
105
102
noImplicitAny:true,
106
-
typeCheck:true, // also accepts "strict"
107
103
tsconfig:true// also accepts a path
108
104
}
109
105
});
110
106
```
111
107
112
-
All the usual TypeScript compiler options are supported, as well as these additional ones:
113
-
114
-
#### typeCheck ####
108
+
It is also possible to override the default configuration for specific files, using ```packages``` configuration:
115
109
116
-
A boolean flag which controls whether the files are type-checked or simply transpiled. Type-checking does add some overhead to the build process as typings need to be loaded and the compiler has more work to do.
110
+
```js
111
+
System.config({
112
+
transpiler:"babel",
113
+
packages: {
114
+
"src": {
115
+
"defaultExtension":"ts",
116
+
"typescriptOptions": {
117
+
"noImplicitAny":true
118
+
}
119
+
}
120
+
}
121
+
});
122
+
```
117
123
118
-
By default compiler errors are written to the console but the build is allowed to continue. To change this behaviour you can use ```typeCheck: "strict"``` in which case the build will be failed when compiler errors are encountered.
124
+
All the usual TypeScript compiler options are supported, as well as these additional ones:
119
125
120
126
#### tsconfig ####
121
127
122
128
A boolean flag which instructs the plugin to load configuration from "tsconfig.json". To override the location of the file set this option to the path of the configuration file, which will be resolved using normal SystemJS resolution.
123
129
124
130
Compiler options which do not conflict with those required by plugin-typescript will be loaded from the ```compilerOptions``` section of the file. Any declaration files contained in the ```files``` array will also be loaded if type-checking is enabled.
125
131
126
-
#### types ####
127
-
128
-
The ```types``` compiler option tells the type-checker which packages have typings available under the *@types* scoped package. As an example if you have installed typings at ```@types/react``` then add ```react``` to the array of strings:
129
-
```json
130
-
{
131
-
"typescriptOptions": {
132
-
"types": ["react"]
133
-
}
134
-
}
135
-
```
136
-
To install typings from @types using jspm:
137
-
```sh
138
-
jspm install npm:@types/react
139
-
```
140
-
141
-
#### typings ####
142
-
143
-
The ```typings``` compiler option tells the type-checker which packages contain their own typings and where they are located, it is an object map:
144
-
145
-
```js
146
-
"typescriptOptions": {
147
-
"typings": {
148
-
"rxjs":"Rx.d.ts", // relative to root of package
149
-
"myownpackage":true// all js files have typings with the same name
150
-
}
151
-
}
152
-
```
153
-
154
-
If a package contains typings for *all* js files in the package then the value should be set to ```true```, otherwise it should contain the path of the bundled typings file, relative to the root of the project.
155
-
156
132
## Features ##
157
133
158
134
#### Hot-Reload support ####
@@ -168,10 +144,6 @@ Rollup is supported when transpiling with ```module: "es6"```. It can help to re
168
144
169
145
When compiling in the browser, compiler errors contain a link to the exact location of the error in the source. This is particularly helpful if you are using Chrome DevTools as your IDE.
170
146
171
-
#### Type-checking over multiple packages ####
172
-
173
-
The type-checker runs across multiple packages if the imported file resolves to a typescript file. This means that if you do ```import "mypackage/index"``` and that resolves to a typescript file then that import will be properly type-checked. You no longer have to handcraft an external declaration file for 'mypackage'.
174
-
175
147
#### Override TypeScript version ####
176
148
177
149
To override the version of TypeScript used by the plugin, add an override to the ```jspm``` section of your package.json
0 commit comments