Skip to content

Commit 71fb8cc

Browse files
committed
Merge remote-tracking branch 'origin/master' into faster-interface-check
* origin/master: (140 commits) test overriding Session.event Update editorServices.ts Fix semantic merge conflict (microsoft#20119) LEGO: check in for master to temporary branch. Moved minified file exclusion Fixed internal safelist For import completion, if multiple re-exports exist, choose the one with the shortest path (microsoft#20049) Bundle fileName with CodeActionCommand (microsoft#19881) Simplify documentHighlights (microsoft#20091) LEGO: check in for master to temporary branch. Support semantic classification of alias (microsoft#20012) In `getContextualTypeForBinaryOperand`, only need to look for `=` assignment operator, not e.g. `+=` (microsoft#20037) lineAction: Use an enum instead of true | false | undefined (microsoft#20086) LEGO: check in for master to temporary branch. cleanup NodeTypingsInstaller remove comments type `event` callback correctly update baselines defer callback and remove handler object Support arbitrary prototype property assignments in navigation bar (microsoft#19923) ...
2 parents 7d35a79 + 6c4c10c commit 71fb8cc

File tree

442 files changed

+17223
-4554
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

442 files changed

+17223
-4554
lines changed

.gitmodules

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[submodule "tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter"]
2+
path = tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter
3+
url = https://github.com/Microsoft/TypeScript-React-Starter
4+
ignore = all
5+
shallow = true
6+
[submodule "tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter"]
7+
path = tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter
8+
url = https://github.com/Microsoft/TypeScript-Node-Starter.git
9+
ignore = all
10+
shallow = true
11+
[submodule "tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter"]
12+
path = tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter
13+
url = https://github.com/Microsoft/TypeScript-React-Native-Starter.git
14+
ignore = all
15+
shallow = true
16+
[submodule "tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter"]
17+
path = tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter
18+
url = https://github.com/Microsoft/TypeScript-Vue-Starter.git
19+
ignore = all
20+
shallow = true
21+
[submodule "tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter"]
22+
path = tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter
23+
url = https://github.com/Microsoft/TypeScript-WeChat-Starter.git
24+
ignore = all
25+
shallow = true

src/compiler/binder.ts

Lines changed: 57 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -16,52 +16,63 @@ namespace ts {
1616
referenced: boolean;
1717
}
1818

19-
export function getModuleInstanceState(node: Node): ModuleInstanceState {
19+
export function getModuleInstanceState(node: ModuleDeclaration): ModuleInstanceState {
20+
return node.body ? getModuleInstanceStateWorker(node.body) : ModuleInstanceState.Instantiated;
21+
}
22+
23+
function getModuleInstanceStateWorker(node: Node): ModuleInstanceState {
2024
// A module is uninstantiated if it contains only
21-
// 1. interface declarations, type alias declarations
22-
if (node.kind === SyntaxKind.InterfaceDeclaration || node.kind === SyntaxKind.TypeAliasDeclaration) {
23-
return ModuleInstanceState.NonInstantiated;
24-
}
25-
// 2. const enum declarations
26-
else if (isConstEnumDeclaration(node)) {
27-
return ModuleInstanceState.ConstEnumOnly;
28-
}
29-
// 3. non-exported import declarations
30-
else if ((node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ImportEqualsDeclaration) && !(hasModifier(node, ModifierFlags.Export))) {
31-
return ModuleInstanceState.NonInstantiated;
32-
}
33-
// 4. other uninstantiated module declarations.
34-
else if (node.kind === SyntaxKind.ModuleBlock) {
35-
let state = ModuleInstanceState.NonInstantiated;
36-
forEachChild(node, n => {
37-
switch (getModuleInstanceState(n)) {
38-
case ModuleInstanceState.NonInstantiated:
39-
// child is non-instantiated - continue searching
40-
return false;
41-
case ModuleInstanceState.ConstEnumOnly:
42-
// child is const enum only - record state and continue searching
43-
state = ModuleInstanceState.ConstEnumOnly;
44-
return false;
45-
case ModuleInstanceState.Instantiated:
46-
// child is instantiated - record state and stop
47-
state = ModuleInstanceState.Instantiated;
48-
return true;
25+
switch (node.kind) {
26+
// 1. interface declarations, type alias declarations
27+
case SyntaxKind.InterfaceDeclaration:
28+
case SyntaxKind.TypeAliasDeclaration:
29+
return ModuleInstanceState.NonInstantiated;
30+
// 2. const enum declarations
31+
case SyntaxKind.EnumDeclaration:
32+
if (isConst(node)) {
33+
return ModuleInstanceState.ConstEnumOnly;
34+
}
35+
break;
36+
// 3. non-exported import declarations
37+
case SyntaxKind.ImportDeclaration:
38+
case SyntaxKind.ImportEqualsDeclaration:
39+
if (!(hasModifier(node, ModifierFlags.Export))) {
40+
return ModuleInstanceState.NonInstantiated;
41+
}
42+
break;
43+
// 4. other uninstantiated module declarations.
44+
case SyntaxKind.ModuleBlock: {
45+
let state = ModuleInstanceState.NonInstantiated;
46+
forEachChild(node, n => {
47+
const childState = getModuleInstanceStateWorker(n);
48+
switch (childState) {
49+
case ModuleInstanceState.NonInstantiated:
50+
// child is non-instantiated - continue searching
51+
return;
52+
case ModuleInstanceState.ConstEnumOnly:
53+
// child is const enum only - record state and continue searching
54+
state = ModuleInstanceState.ConstEnumOnly;
55+
return;
56+
case ModuleInstanceState.Instantiated:
57+
// child is instantiated - record state and stop
58+
state = ModuleInstanceState.Instantiated;
59+
return true;
60+
default:
61+
Debug.assertNever(childState);
62+
}
63+
});
64+
return state;
65+
}
66+
case SyntaxKind.ModuleDeclaration:
67+
return getModuleInstanceState(node as ModuleDeclaration);
68+
case SyntaxKind.Identifier:
69+
// Only jsdoc typedef definition can exist in jsdoc namespace, and it should
70+
// be considered the same as type alias
71+
if ((<Identifier>node).isInJSDocNamespace) {
72+
return ModuleInstanceState.NonInstantiated;
4973
}
50-
});
51-
return state;
52-
}
53-
else if (node.kind === SyntaxKind.ModuleDeclaration) {
54-
const body = (<ModuleDeclaration>node).body;
55-
return body ? getModuleInstanceState(body) : ModuleInstanceState.Instantiated;
56-
}
57-
// Only jsdoc typedef definition can exist in jsdoc namespace, and it should
58-
// be considered the same as type alias
59-
else if (node.kind === SyntaxKind.Identifier && (<Identifier>node).isInJSDocNamespace) {
60-
return ModuleInstanceState.NonInstantiated;
61-
}
62-
else {
63-
return ModuleInstanceState.Instantiated;
6474
}
75+
return ModuleInstanceState.Instantiated;
6576
}
6677

6778
const enum ContainerFlags {
@@ -1680,7 +1691,7 @@ namespace ts {
16801691

16811692
function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: __String) {
16821693
const symbol = createSymbol(symbolFlags, name);
1683-
if (symbolFlags & SymbolFlags.EnumMember) {
1694+
if (symbolFlags & (SymbolFlags.EnumMember | SymbolFlags.ClassMember)) {
16841695
symbol.parent = container.symbol;
16851696
}
16861697
addDeclarationToSymbol(symbol, node, symbolFlags);
@@ -1835,7 +1846,7 @@ namespace ts {
18351846
}
18361847

18371848
function checkStrictModeNumericLiteral(node: NumericLiteral) {
1838-
if (inStrictMode && node.numericLiteralFlags & NumericLiteralFlags.Octal) {
1849+
if (inStrictMode && node.numericLiteralFlags & TokenFlags.Octal) {
18391850
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));
18401851
}
18411852
}
@@ -3319,7 +3330,7 @@ namespace ts {
33193330
break;
33203331

33213332
case SyntaxKind.NumericLiteral:
3322-
if ((<NumericLiteral>node).numericLiteralFlags & NumericLiteralFlags.BinaryOrOctalSpecifier) {
3333+
if ((<NumericLiteral>node).numericLiteralFlags & TokenFlags.BinaryOrOctalSpecifier) {
33233334
transformFlags |= TransformFlags.AssertES2015;
33243335
}
33253336
break;

src/compiler/builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ namespace ts {
7777
}
7878

7979
export interface BuilderOptions {
80-
getCanonicalFileName: (fileName: string) => string;
80+
getCanonicalFileName: GetCanonicalFileName;
8181
computeHash: (data: string) => string;
8282
}
8383

0 commit comments

Comments
 (0)