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
@@ -50,16 +53,18 @@ to restart the server to take the changes into account.
50
53
### Quirks with `tsconfig.json`
51
54
52
55
Additionally, depending on what you're doing, you may notice that your tweaks to
53
-
`tsconfig.json`don't get picked up by the compiler at all.
56
+
`tsconfig.json`aren't applied *exactly* as you might expect.
54
57
55
58
#### The Problem
56
59
57
-
The configuration file is used by both Ember CLI/[broccoli](http://broccolijs.com/)
58
-
and `tsc` command line compiler (used by e.g. [VS Code](http://code.visualstudio.com/),
59
-
JetBrains IDEs, etc.).
60
+
The configuration file is used by both Ember CLI (via [broccoli]) and the `tsc`
61
+
command line compiler (used by e.g. [VS Code], JetBrains IDEs, etc.).
62
+
63
+
[broccoli]: http://broccolijs.com/
64
+
[VS Code]: http://code.visualstudio.com/
60
65
61
66
Broccoli controls the inputs and the output folder of the various build steps
62
-
that make the Ember build pipeline. Its expectation are impacted by Typescript
67
+
that make the Ember build pipeline. Its expectation are impacted by TypeScript
63
68
configuration properties like "include", "exclude", "outFile", "outDir".
64
69
65
70
We want to allow you to change unrelated properties in the tsconfig file.
@@ -68,13 +73,18 @@ We want to allow you to change unrelated properties in the tsconfig file.
68
73
69
74
This addon takes the following approach to allow this dual use:
70
75
71
-
- it starts with the following[blueprint](https://github.com/emberwatch/ember-cli-typescript/blob/master/blueprints/ember-cli-typescript/files/tsconfig.json)
76
+
- it starts with the default[blueprint].
72
77
73
78
- the generated tsconfig file does not set "outDir" and sets "noEmit" to true.
74
79
This allows you to run vscode and tsc without creating `.js` files throughout
75
80
your codebase.
76
81
77
-
- before calling broccoli the addon removes "outDir" and sets "noEmit" and "includes"
82
+
- before calling broccoli the addon removes any configured `outDir`, sets the
83
+
`noEmit` option to false (so that the compiler will emit files for consumption
84
+
by your app!), and removes all values set for `include`, since we use Broccoli
Here is the short list of things which do *not* work yet.
122
128
123
-
### Extending from framework entities using `class` syntax
124
-
125
-
```js
126
-
exportdefaultMyComponentextendsEmber.Component {
127
-
}
128
-
```
129
-
130
129
### Type safety when invoking actions
131
130
132
-
```ts
131
+
TypeScript won't detect a mismatch between this action and the corresponding
132
+
call in the template:
133
+
134
+
```typescript
133
135
actions: {
134
136
turnWheel(degrees: number) {
135
137
...
@@ -138,37 +140,44 @@ actions: {
138
140
```
139
141
140
142
```hbs
141
-
<!-- TypeScript compiler won't detect this type mismatch -->
142
143
<button onclick={{action 'turnWheel' 'NOT-A-NUMBER'}}> Click Me </button>
143
144
```
144
145
145
-
```js
146
+
Likewise, it won't notice a problem when you use `send`:
147
+
148
+
```typescript
146
149
// TypeScript compiler won't detect this type mismatch
147
150
this.send('turnWheel', 'ALSO-NOT-A-NUMBER');
148
151
```
149
152
150
153
### Type safety when invoking KVO compliant accessors or mutators
151
154
152
-
```ts
155
+
When you use `Ember.get` or `Ember.set`, TypeScript won't (yet!) warn you that
156
+
you're using the wrong type. So in `foo()` here, this will pass the compiler but
157
+
be wrong at runtime:
158
+
159
+
```typescript
153
160
Ember.Object.extend({
154
161
urls: <string[]> null,
155
-
port: 4200,
162
+
port: 4200,// number
156
163
init() {
157
164
this._super(...arguments);
158
165
this.set('urls', []);
159
166
},
160
167
foo() {
161
168
// TypeScript won't detect these type mismatches
162
169
this.get('urls').addObject(51);
163
-
this.set('port', 3000);
170
+
this.set('port', '3000');
164
171
}
165
172
});
166
173
```
167
174
168
175
169
-
### The TypeDefs I need to reference are not in node_modules/@types
176
+
### The type definitions I need to reference are not in `node_modules/@types`
170
177
171
-
By default `ember-cli-typescript` loads up any type defs found in node_modules/@types. If the type defs you need are not found here you can register a custom `path` in the tsconfig.json file
178
+
By default `ember-cli-typescript` loads up any type defs found in
179
+
`node_modules/@types`. If the type defs you need are not found here you can
180
+
register a custom `path` in the tsconfig.json file:
172
181
173
182
```json
174
183
// tsconfig.json
@@ -178,9 +187,6 @@ By default `ember-cli-typescript` loads up any type defs found in node_modules/@
0 commit comments