Skip to content

Enable '--strictNullChecks' #22088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
105 commits merged into from
May 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
8deee11
Enable '--strictNullChecks'
Feb 21, 2018
1484c0a
Merge branch 'master' into undefinedzilla
Feb 27, 2018
cf4f760
Merge branch 'master' into undefinedzilla
Feb 28, 2018
e31b4e9
Merge branch 'master' into undefinedzilla
Mar 1, 2018
28991e1
Fix API baselines
Mar 1, 2018
f600af7
Merge branch 'master' into undefinedzilla
Mar 2, 2018
3622f1c
Merge branch 'master' into undefinedzilla
Mar 3, 2018
5632d41
Merge branch 'master' into undefinedzilla
Mar 5, 2018
376adac
Merge branch 'master' into undefinedzilla
Mar 8, 2018
7b21e6e
Merge branch 'master' into undefinedzilla
Mar 12, 2018
36a28f1
Merge branch 'master' into undefinedzilla
Mar 13, 2018
f7f10d6
Merge branch 'master' into undefinedzilla
Mar 14, 2018
df0b2a3
Merge branch 'master' into undefinedzilla
Mar 14, 2018
555e1ae
Merge branch 'master' into undefinedzilla
Mar 16, 2018
40cd3ce
Merge branch 'master' into undefinedzilla
Mar 16, 2018
7a8dc71
Merge branch 'master' into undefinedzilla
Mar 16, 2018
cc0b4ca
Merge branch 'master' into undefinedzilla
Mar 19, 2018
a108007
Merge branch 'master' into undefinedzilla
Mar 20, 2018
99a8e68
Merge branch 'master' into undefinedzilla
Mar 23, 2018
df4b16d
Merge branch 'master' into undefinedzilla
Mar 23, 2018
cc3e642
Merge branch 'master' into undefinedzilla
Mar 23, 2018
e39a1b2
Merge branch 'master' into undefinedzilla
Mar 28, 2018
38b3cc2
Merge branch 'master' into undefinedzilla
Mar 29, 2018
f216df4
Merge branch 'master' into undefinedzilla
Mar 30, 2018
62bded5
Merge branch 'master' into undefinedzilla
Apr 4, 2018
d3dac33
Merge branch 'master' into undefinedzilla
Apr 4, 2018
da8639f
Merge branch 'master' into undefinedzilla
Apr 6, 2018
d83ba16
Merge branch 'master' into undefinedzilla
Apr 6, 2018
1116c90
Merge branch 'master' into undefinedzilla
Apr 9, 2018
34906ef
Merge branch 'master' into undefinedzilla
Apr 10, 2018
3b721e7
Merge branch 'master' into undefinedzilla
Apr 12, 2018
6556a30
Merge branch 'master' into undefinedzilla
Apr 12, 2018
edb3234
Merge branch 'master' into undefinedzilla
Apr 12, 2018
8521b9d
Merge branch 'master' into undefinedzilla
Apr 16, 2018
d3871cf
Merge branch 'master' into undefinedzilla
Apr 17, 2018
e2fd71b
Merge branch 'master' into undefinedzilla
Apr 17, 2018
174a011
Merge branch 'master' into undefinedzilla
Apr 18, 2018
3895991
Merge branch 'master' into undefinedzilla
Apr 19, 2018
76dcc5c
Merge branch 'master' into undefinedzilla
Apr 19, 2018
5d34edc
Merge branch 'master' into undefinedzilla
Apr 19, 2018
676dc93
Merge branch 'master' into undefinedzilla
Apr 20, 2018
1fe25f1
Merge branch 'master' into undefinedzilla
Apr 20, 2018
9b0fad1
Merge branch 'master' into undefinedzilla
Apr 20, 2018
5c59f4c
Merge branch 'master' into undefinedzilla
Apr 23, 2018
f803f19
Merge branch 'master' into undefinedzilla
Apr 23, 2018
383cd70
Merge branch 'master' into undefinedzilla
Apr 24, 2018
6f77c34
Make sys.getEnvironmentVariable non-nullable
mhegazy Apr 24, 2018
6152c9b
make properties optional instead of using `| undefined` in thier type
mhegazy Apr 24, 2018
8cda69c
reportDiagnostics should be required
mhegazy Apr 24, 2018
b0bcef5
Declare firstAccessor as non-nullable
mhegazy Apr 24, 2018
4d63f37
Make `some` a type guard
mhegazy Apr 24, 2018
e4d8b76
Fix `getEnvironmentVariable` definition in tests
mhegazy Apr 24, 2018
34a0611
Pretend transformFlags are always defined
mhegazy Apr 24, 2018
0900823
Fix one more use of sys.getEnvironmentVariable
mhegazy Apr 24, 2018
c10ace5
`requiredResponse` accepts undefined, remove assertions
mhegazy Apr 24, 2018
b98cbbb
Mark optional properties as optional instead of using `| undefined`
mhegazy Apr 24, 2018
660477f
Merge branch 'undefinedzilla' of https://github.com/Microsoft/TypeScr…
mhegazy Apr 24, 2018
ddffe1f
Mark optional properties as optional instead of using ` | undefined`
mhegazy Apr 24, 2018
ced45f4
Remove unnecessary null assertions
mhegazy Apr 24, 2018
95fdfaf
Put the bang on the declaration instead of every use
mhegazy Apr 24, 2018
0b53a42
Make `createMapFromTemplate` require a parameter
mhegazy Apr 24, 2018
bd0b455
Mark `EmitResult.emittedFiles` and `EmitResult.sourceMaps` as optional
mhegazy Apr 24, 2018
971fa9a
Plumb through undefined in emitLsit and EmitExpressionList
mhegazy Apr 24, 2018
94c416d
`ElementAccessExpression.argumentExpression` can not be `undefined`
mhegazy Apr 24, 2018
54a37db
Add overloads for `writeTokenText`
mhegazy Apr 25, 2018
4c8ec96
Make `shouldWriteSeparatingLineTerminator` argument non-nullable
mhegazy Apr 25, 2018
3f066aa
Make `synthesizedNodeStartsOnNewLine` argument required
mhegazy Apr 25, 2018
9867f7d
`PropertyAssignment.initializer` cannot be undefined
mhegazy Apr 25, 2018
4dc981f
Use one `!` at declaration site instead of on every use site
mhegazy Apr 25, 2018
faf868f
Capture host in a constant and avoid null assertions
mhegazy Apr 25, 2018
3c0dc90
Remove few more unused assertions
mhegazy Apr 25, 2018
828d18b
Merge remote-tracking branch 'origin/master' into undefinedzilla
mhegazy Apr 25, 2018
334b6d8
Update baselines
mhegazy Apr 25, 2018
11acd0b
Use parameter defaults
mhegazy Apr 25, 2018
1f63084
Update baselines
mhegazy Apr 25, 2018
8d562da
Fix lint
Apr 25, 2018
7c30658
Merge branch 'master' into undefinedzilla
Apr 25, 2018
e958ece
Make Symbol#valueDeclaration and Symbol#declarations non-optional to …
Apr 25, 2018
cd5c852
Make Node#symbol and Type#symbol non-optional to reduce assertions
Apr 25, 2018
03d284d
Make `flags` non-nullable to reduce assertions
Apr 25, 2018
32d0421
Merge branch 'master' into undefinedzilla
Apr 25, 2018
0a0653e
Merge branch 'master' into undefinedzilla
Apr 26, 2018
301f8c2
Merge branch 'master' into undefinedzilla
Apr 30, 2018
c59c7ec
Convert some asserts to type guards
mhegazy Apr 30, 2018
e770b1d
Merge branch 'undefinedzilla' of https://github.com/Microsoft/TypeScr…
mhegazy Apr 30, 2018
8b7a620
Make `isNonLocalAlias` a type guard
mhegazy May 1, 2018
86d3334
Add overload for `getSymbolOfNode` for `Declaration`
mhegazy May 1, 2018
9d2914a
Some more `getSymbolOfNode` changes
mhegazy May 1, 2018
1347f67
Merge branch 'master' into undefinedzilla
May 1, 2018
366cc3e
Push undefined suppression into `typeToTypeNodeHelper`
mhegazy May 2, 2018
5cedbc8
`NodeBuilderContext.tracker` is never `undefined`
mhegazy May 2, 2018
1f69c48
use `Debug.assertDefined`
mhegazy May 2, 2018
596c644
Remove unnecessary tag
mhegazy May 2, 2018
321f1c2
Mark `LiteralType.freshType` and `LiteralTupe.regularType` as required
mhegazy May 2, 2018
42f7daa
Merge branch 'master' into undefinedzilla
May 15, 2018
99f142b
Merge from master
May 16, 2018
a369a80
Merge branch 'master' into undefinedzilla
May 17, 2018
afea2dc
Merge branch 'master' into undefinedzilla
May 18, 2018
08d061d
Merge branch 'master' into undefinedzilla
May 18, 2018
30ad569
Merge branch 'master' into undefinedzilla
May 21, 2018
133d006
Merge branch 'master' into undefinedzilla
May 22, 2018
95b3b7a
Merge branch 'master' into undefinedzilla
May 22, 2018
00dab27
Merge branch 'master' into undefinedzilla
May 22, 2018
2b1f78e
Merge branch 'master' into undefinedzilla
May 22, 2018
c0672e2
Merge branch 'master' into undefinedzilla
May 22, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ function getCompilerSettings(base, useBuiltCompiler) {
for (const key in base) {
copy[key] = base[key];
}
copy.strictNullChecks = true;
if (!useDebugMode) {
if (copy.removeComments === undefined) copy.removeComments = true;
}
Expand Down
2 changes: 1 addition & 1 deletion Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
else {
options += " --lib es5";
}
options += " --noUnusedLocals --noUnusedParameters";
options += " --noUnusedLocals --noUnusedParameters --strictNullChecks";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just --strict?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and same in gulpfile

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and same in tsconfig.json

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--strictPropertyInitialization gives a ton of errors, as does --strictFunctionTypes.


var cmd = host + " " + compilerPath + " " + options + " ";
cmd = cmd + sources.join(" ");
Expand Down
8 changes: 4 additions & 4 deletions scripts/buildProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function endsWith(s: string, suffix: string) {
}

function isStringEnum(declaration: ts.EnumDeclaration) {
return declaration.members.length && declaration.members.every(m => m.initializer && m.initializer.kind === ts.SyntaxKind.StringLiteral);
return declaration.members.length && declaration.members.every(m => !!m.initializer && m.initializer.kind === ts.SyntaxKind.StringLiteral);
}

class DeclarationsWalker {
Expand All @@ -30,7 +30,7 @@ class DeclarationsWalker {
text += "\ndeclare namespace ts {\n";
text += " // these types are empty stubs for types from services and should not be used directly\n"
for (const type of walker.removedTypes) {
text += ` export type ${type.symbol.name} = never;\n`;
text += ` export type ${type.symbol!.name} = never;\n`;
}
text += "}"
}
Expand Down Expand Up @@ -130,7 +130,7 @@ function writeProtocolFile(outputFile: string, protocolTs: string, typeScriptSer
function getInitialDtsFileForProtocol() {
const program = ts.createProgram([protocolTs, typeScriptServicesDts], options);

let protocolDts: string;
let protocolDts: string | undefined;
program.emit(program.getSourceFile(protocolTs), (file, content) => {
if (endsWith(file, ".d.ts")) {
protocolDts = content;
Expand Down Expand Up @@ -162,7 +162,7 @@ function writeProtocolFile(outputFile: string, protocolTs: string, typeScriptSer
let protocolDts = getInitialDtsFileForProtocol();
const program = getProgramWithProtocolText(protocolDts, /*includeTypeScriptServices*/ true);

const protocolFile = program.getSourceFile("protocol.d.ts");
const protocolFile = program.getSourceFile("protocol.d.ts")!;
const extraDeclarations = DeclarationsWalker.getExtraDeclarations(program.getTypeChecker(), protocolFile);
if (extraDeclarations) {
protocolDts += extraDeclarations;
Expand Down
2 changes: 1 addition & 1 deletion scripts/processDiagnosticMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function main(): void {
}

const inputFilePath = sys.args[0].replace(/\\/g, "/");
const inputStr = sys.readFile(inputFilePath);
const inputStr = sys.readFile(inputFilePath)!;

const diagnosticMessagesJson: { [key: string]: DiagnosticDetails } = JSON.parse(inputStr);

Expand Down
2 changes: 1 addition & 1 deletion scripts/tslint/rules/noInOperatorRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class Rule extends Lint.Rules.AbstractRule {
function walk(ctx: Lint.WalkContext<void>): void {
ts.forEachChild(ctx.sourceFile, recur);
function recur(node: ts.Node): void {
if (node.kind === ts.SyntaxKind.InKeyword && node.parent.kind === ts.SyntaxKind.BinaryExpression) {
if (node.kind === ts.SyntaxKind.InKeyword && node.parent!.kind === ts.SyntaxKind.BinaryExpression) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parent is not optional, why is this required?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses our published typescript.d.ts, not the one in this PR -- so if we merge this and the newest published version has parent non-optional, we'll have to change it then.

ctx.addFailureAtNode(node, Rule.FAILURE_STRING);
}
}
Expand Down
98 changes: 0 additions & 98 deletions scripts/tslint/rules/noUnnecessaryTypeAssertion2Rule.ts

This file was deleted.

Loading