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: docs/ts/using-ts-effectively.md
+17-13
Original file line number
Diff line number
Diff line change
@@ -8,24 +8,28 @@ Some specific tips for success on the technical front:
8
8
9
9
First, use the _strictest_ strictness settings that our typings allow (currently all strictness settings except `strictFunctionTypes`). While it may be tempting to start with the _loosest_ strictness settings and then to tighten them down as you go, this will actually mean that "getting your app type-checking" will become a repeated process—getting it type-checking with every new strictness setting you enable—rather than something you do just once.
10
10
11
-
The full recommended _strictness_ settings in your `"compilerOptions"` hash:
11
+
The full recommended _strictness_ settings in your `"compilerOptions"` hash (which are also the settings generated by the ember-cli-typescript blueprint):
12
12
13
-
```json
13
+
```json5
14
14
{
15
-
"noImplicitAny": true,
16
-
"noImplicitThis": true,
17
-
"alwaysStrict": true,
18
-
"strictNullChecks": true,
19
-
"strictPropertyInitialization": true,
20
-
"noFallthroughCasesInSwitch": true,
21
-
"noUnusedLocals": true,
22
-
"noUnusedParameters": true,
23
-
"noImplicitReturns": true,
24
-
"noUncheckedIndexedAccess": true,
15
+
"compilerOptions": {
16
+
// Strictness settings -- you should *not* change these: Ember code is not
17
+
// guaranteed to type check with these set to looser values.
18
+
"strict":true,
19
+
"noUncheckedIndexedAccess":true,
20
+
21
+
// You should feel free to change these, especially if you are already
22
+
// covering them via linting (e.g. with @typescript-eslint).
23
+
"noFallthroughCasesInSwitch":true,
24
+
"noUnusedLocals":true,
25
+
"noUnusedParameters":true,
26
+
"noImplicitReturns":true,
27
+
"noPropertyAccessFromIndexSignature":true,
28
+
}
25
29
}
26
30
```
27
31
28
-
A good approach is to start at your "leaf" files (the ones that don't import anything else from your app, only Ember types) and then work your way back inward toward the most core types that are used everywhere. Often the highest-value modules are your Ember Data models and any core services that are used everywhere else in the app – and those are also the ones that tend to have the most cascading effects (having to update _tons_ of other places in your app) when you type them later in the process.
32
+
A good approach is to start at your "leaf" modules (the ones that don't import anything else from your app, only Ember or third-party types) and then work your way back inward toward the most core modules that are used everywhere. Often the highest-value modules are your Ember Data models and any core services that are used everywhere else in the app – and those are also the ones that tend to have the most cascading effects (having to update _tons_ of other places in your app) when you type them later in the process.
29
33
30
34
Finally, leave `"noEmitOnError": true` (the default) in the `"compilerOptions"` hash in your `tsconfig.json`. This will fail your build if you have type errors, which gives you the fastest feedback as you add types.
0 commit comments