Skip to content

Commit c2889fe

Browse files
committed
Add recommended strictness values.
1 parent b4617da commit c2889fe

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,19 @@ If you are porting an existing app to TypeScript, you can install this addon and
120120

121121
Some specific tips for success on the technical front:
122122

123-
* Use the *strictest* strictness settings that our typings allow. 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.
123+
* Use the *strictest* strictness settings that our typings allow. 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. The only strictness setting you should turn *off* is `strictFunctionTypes`, which our current type definitions do not support. The recommended *strictness* settings in your `"compilerOptions"` hash:
124+
125+
```
126+
"noImplicitAny": true,
127+
"noImplicitThis": true,
128+
"alwaysStrict": true,
129+
"strictNullChecks": true,
130+
"strictPropertyInitialization": true,
131+
"noFallthroughCasesInSwitch": true,
132+
"noUnusedLocals": true,
133+
"noUnusedParameters": true,
134+
"noImplicitReturns": true,
135+
```
124136
125137
* Make liberal use of `any` for things you don't have types for as you go, and come back and fill them in later. This will let you do the strictest strictness settings but with an escape hatch that lets you say "We will come back to this when we have more idea how to handle it."
126138

tsconfig.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
"allowJs": false,
55
"moduleResolution": "node",
66
"noEmitOnError": true,
7+
"strictNullChecks": true,
8+
"strictPropertyInitialization": true,
9+
"alwaysStrict": true,
10+
"noImplicitAny": true,
11+
"noFallthroughCasesInSwitch": true,
12+
"noImplicitThis": true,
13+
"noUnusedLocals": true,
14+
"noUnusedParameters": true,
15+
"noImplicitReturns": true,
716
"inlineSourceMap": true,
817
"inlineSources": true,
918
"baseUrl": ".",

0 commit comments

Comments
 (0)