Skip to content

Commit 4464a41

Browse files
committed
Merge branch 'master' into stringLiteralCompletions
2 parents 7b0d664 + f28d535 commit 4464a41

8 files changed

Lines changed: 893 additions & 822 deletions

File tree

.npmignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
built
22
doc
3+
internal
4+
issue_template.md
35
lib/README.md
6+
pull_request_template.md
47
scripts
58
src
69
tests
7-
internal
810
tslint.json
911
Jakefile.js
1012
.editorconfig

src/compiler/checker.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -574,18 +574,28 @@ namespace ts {
574574
function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration: VariableDeclaration, usage: Node): boolean {
575575
const container = getEnclosingBlockScopeContainer(declaration);
576576

577-
if (declaration.parent.parent.kind === SyntaxKind.VariableStatement ||
578-
declaration.parent.parent.kind === SyntaxKind.ForStatement) {
579-
// variable statement/for statement case,
580-
// use site should not be inside variable declaration (initializer of declaration or binding element)
581-
return isSameScopeDescendentOf(usage, declaration, container);
577+
switch (declaration.parent.parent.kind) {
578+
case SyntaxKind.VariableStatement:
579+
case SyntaxKind.ForStatement:
580+
case SyntaxKind.ForOfStatement:
581+
// variable statement/for/for-of statement case,
582+
// use site should not be inside variable declaration (initializer of declaration or binding element)
583+
if (isSameScopeDescendentOf(usage, declaration, container)) {
584+
return true;
585+
}
586+
break;
582587
}
583-
else if (declaration.parent.parent.kind === SyntaxKind.ForOfStatement ||
584-
declaration.parent.parent.kind === SyntaxKind.ForInStatement) {
585-
// ForIn/ForOf case - use site should not be used in expression part
586-
const expression = (<ForInStatement | ForOfStatement>declaration.parent.parent).expression;
587-
return isSameScopeDescendentOf(usage, expression, container);
588+
589+
switch (declaration.parent.parent.kind) {
590+
case SyntaxKind.ForInStatement:
591+
case SyntaxKind.ForOfStatement:
592+
// ForIn/ForOf case - use site should not be used in expression part
593+
if (isSameScopeDescendentOf(usage, (<ForInStatement | ForOfStatement>declaration.parent.parent).expression, container)) {
594+
return true;
595+
}
588596
}
597+
598+
return false;
589599
}
590600

591601
function isUsedInFunctionOrNonStaticProperty(declaration: Declaration, usage: Node): boolean {
@@ -7989,7 +7999,7 @@ namespace ts {
79897999
const defaultsToDeclaredType = !strictNullChecks || type.flags & TypeFlags.Any || !declaration ||
79908000
getRootDeclaration(declaration).kind === SyntaxKind.Parameter || isInAmbientContext(declaration) ||
79918001
getContainingFunctionOrModule(declaration) !== getContainingFunctionOrModule(node);
7992-
const flowType = getFlowTypeOfReference(node, type, defaultsToDeclaredType ? type : undefinedType);
8002+
const flowType = getFlowTypeOfReference(node, type, defaultsToDeclaredType ? type : addNullableKind(type, TypeFlags.Undefined));
79938003
if (strictNullChecks && !(type.flags & TypeFlags.Any) && !(getNullableKind(type) & TypeFlags.Undefined) && getNullableKind(flowType) & TypeFlags.Undefined) {
79948004
error(node, Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
79958005
// Return the declared type to reduce follow-on errors

src/lib/es2015.core.d.ts

Lines changed: 67 additions & 62 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)