Skip to content

Commit 801edb2

Browse files
committed
Merge branch 'master' into string-literal-refactor
2 parents ccfbb67 + 1aaa2ec commit 801edb2

File tree

292 files changed

+7354
-3180
lines changed

Some content is hidden

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

292 files changed

+7354
-3180
lines changed

.eslintrc.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,20 @@
1818
"@typescript-eslint/array-type": "error",
1919

2020
"camelcase": "off",
21-
"@typescript-eslint/camelcase": ["error", { "properties": "never", "allow": ["^[A-Za-z][a-zA-Za-z]+_[A-Za-z]+$"] }],
21+
"@typescript-eslint/naming-convention": [
22+
"error",
23+
{ "selector": "typeLike", "format": ["PascalCase"], "filter": { "regex": "^(__String|[A-Za-z]+_[A-Za-z]+)$", "match": false } },
24+
{ "selector": "interface", "format": ["PascalCase"], "custom": { "regex": "^I[A-Z]", "match": false }, "filter": { "regex": "^I(Arguments|TextWriter|O([A-Z][a-z]+[A-Za-z]*)?)$", "match": false } },
25+
{ "selector": "variable", "format": ["camelCase", "PascalCase", "UPPER_CASE"], "leadingUnderscore": "allow", "filter": { "regex": "^(_{1,2}filename|_{1,2}dirname|_+|[A-Za-z]+_[A-Za-z]+)$", "match": false } },
26+
{ "selector": "function", "format": ["camelCase", "PascalCase"], "leadingUnderscore": "allow", "filter": { "regex": "^[A-Za-z]+_[A-Za-z]+$", "match": false } },
27+
{ "selector": "parameter", "format": ["camelCase"], "leadingUnderscore": "allow", "filter": { "regex": "^(_+|[A-Za-z]+_[A-Z][a-z]+)$", "match": false } },
28+
{ "selector": "method", "format": ["camelCase", "PascalCase"], "leadingUnderscore": "allow", "filter": { "regex": "^[A-Za-z]+_[A-Za-z]+$", "match": false } },
29+
{ "selector": "memberLike", "format": ["camelCase"], "leadingUnderscore": "allow", "filter": { "regex": "^[A-Za-z]+_[A-Za-z]+$", "match": false } },
30+
{ "selector": "enumMember", "format": ["camelCase", "PascalCase"], "leadingUnderscore": "allow", "filter": { "regex": "^[A-Za-z]+_[A-Za-z]+$", "match": false } },
31+
{ "selector": "property", "format": null }
32+
],
2233

23-
"@typescript-eslint/class-name-casing": "error",
2434
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
25-
"@typescript-eslint/interface-name-prefix": "error",
2635
"@typescript-eslint/no-inferrable-types": "error",
2736
"@typescript-eslint/no-misused-new": "error",
2837
"@typescript-eslint/no-this-alias": "error",

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@
5454
"@types/through2": "latest",
5555
"@types/travis-fold": "latest",
5656
"@types/xml2js": "^0.4.0",
57-
"@typescript-eslint/eslint-plugin": "2.27.0",
58-
"@typescript-eslint/experimental-utils": "2.27.0",
59-
"@typescript-eslint/parser": "2.27.0",
57+
"@typescript-eslint/eslint-plugin": "^3.4.1-alpha.1",
58+
"@typescript-eslint/experimental-utils": "^3.4.1-alpha.1",
59+
"@typescript-eslint/parser": "^3.4.1-alpha.1",
6060
"async": "latest",
6161
"azure-devops-node-api": "^10.1.0",
6262
"browser-resolve": "^1.11.2",
@@ -97,7 +97,7 @@
9797
"source-map-support": "latest",
9898
"through2": "latest",
9999
"travis-fold": "latest",
100-
"typescript": "^3.9.3",
100+
"typescript": "^4.0.0-dev.20200624",
101101
"vinyl": "latest",
102102
"vinyl-sourcemaps-apply": "latest",
103103
"xml2js": "^0.4.19"

scripts/build/tests.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,23 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode,
7777
// timeout normally isn"t necessary but Travis-CI has been timing out on compiler baselines occasionally
7878
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
7979
if (!runInParallel) {
80-
args.push(failed ? "scripts/run-failed-tests.js" : mochaJs);
80+
args.push(mochaJs);
8181
args.push("-R", "scripts/failed-tests");
8282
args.push("-O", '"reporter=' + reporter + (keepFailed ? ",keepFailed=true" : "") + '"');
8383
if (tests) {
8484
args.push("-g", `"${tests}"`);
8585
}
86+
if (failed) {
87+
const grep = fs.readFileSync(".failed-tests", "utf8")
88+
.split(/\r?\n/g)
89+
.map(test => test.trim())
90+
.filter(test => test.length > 0)
91+
.map(regExpEscape)
92+
.join("|");
93+
const file = path.join(os.tmpdir(), ".failed-tests.json");
94+
fs.writeFileSync(file, JSON.stringify({ grep }), "utf8");
95+
args.push("--config", file);
96+
}
8697
if (colors) {
8798
args.push("--colors");
8899
}
@@ -203,3 +214,7 @@ function restoreSavedNodeEnv() {
203214
function deleteTemporaryProjectOutput() {
204215
return del(path.join(exports.localBaseline, "projectOutput/"));
205216
}
217+
218+
function regExpEscape(text) {
219+
return text.replace(/[.*+?^${}()|\[\]\\]/g, '\\$&');
220+
}

scripts/run-failed-tests.js

Lines changed: 0 additions & 97 deletions
This file was deleted.

src/compiler/binder.ts

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace ts {
1515
referenced: boolean;
1616
}
1717

18-
export function getModuleInstanceState(node: ModuleDeclaration, visited?: Map<ModuleInstanceState | undefined>): ModuleInstanceState {
18+
export function getModuleInstanceState(node: ModuleDeclaration, visited?: Map<number, ModuleInstanceState | undefined>): ModuleInstanceState {
1919
if (node.body && !node.body.parent) {
2020
// getModuleInstanceStateForAliasTarget needs to walk up the parent chain, so parent pointers must be set on this tree already
2121
setParent(node.body, node);
@@ -24,8 +24,8 @@ namespace ts {
2424
return node.body ? getModuleInstanceStateCached(node.body, visited) : ModuleInstanceState.Instantiated;
2525
}
2626

27-
function getModuleInstanceStateCached(node: Node, visited = createMap<ModuleInstanceState | undefined>()) {
28-
const nodeId = "" + getNodeId(node);
27+
function getModuleInstanceStateCached(node: Node, visited = new Map<number, ModuleInstanceState | undefined>()) {
28+
const nodeId = getNodeId(node);
2929
if (visited.has(nodeId)) {
3030
return visited.get(nodeId) || ModuleInstanceState.NonInstantiated;
3131
}
@@ -35,7 +35,7 @@ namespace ts {
3535
return result;
3636
}
3737

38-
function getModuleInstanceStateWorker(node: Node, visited: Map<ModuleInstanceState | undefined>): ModuleInstanceState {
38+
function getModuleInstanceStateWorker(node: Node, visited: Map<number, ModuleInstanceState | undefined>): ModuleInstanceState {
3939
// A module is uninstantiated if it contains only
4040
switch (node.kind) {
4141
// 1. interface declarations, type alias declarations
@@ -107,7 +107,7 @@ namespace ts {
107107
return ModuleInstanceState.Instantiated;
108108
}
109109

110-
function getModuleInstanceStateForAliasTarget(specifier: ExportSpecifier, visited: Map<ModuleInstanceState | undefined>) {
110+
function getModuleInstanceStateForAliasTarget(specifier: ExportSpecifier, visited: Map<number, ModuleInstanceState | undefined>) {
111111
const name = specifier.propertyName || specifier.name;
112112
let p: Node | undefined = specifier.parent;
113113
while (p) {
@@ -2109,20 +2109,39 @@ namespace ts {
21092109
}
21102110

21112111
// The binder visits every node in the syntax tree so it is a convenient place to perform a single localized
2112-
// check for reserved words used as identifiers in strict mode code.
2113-
function checkStrictModeIdentifier(node: Identifier) {
2114-
if (inStrictMode &&
2115-
node.originalKeywordKind! >= SyntaxKind.FirstFutureReservedWord &&
2116-
node.originalKeywordKind! <= SyntaxKind.LastFutureReservedWord &&
2117-
!isIdentifierName(node) &&
2112+
// check for reserved words used as identifiers in strict mode code, as well as `yield` or `await` in
2113+
// [Yield] or [Await] contexts, respectively.
2114+
function checkContextualIdentifier(node: Identifier) {
2115+
// Report error only if there are no parse errors in file
2116+
if (!file.parseDiagnostics.length &&
21182117
!(node.flags & NodeFlags.Ambient) &&
2119-
!(node.flags & NodeFlags.JSDoc)) {
2118+
!(node.flags & NodeFlags.JSDoc) &&
2119+
!isIdentifierName(node)) {
21202120

2121-
// Report error only if there are no parse errors in file
2122-
if (!file.parseDiagnostics.length) {
2121+
// strict mode identifiers
2122+
if (inStrictMode &&
2123+
node.originalKeywordKind! >= SyntaxKind.FirstFutureReservedWord &&
2124+
node.originalKeywordKind! <= SyntaxKind.LastFutureReservedWord) {
21232125
file.bindDiagnostics.push(createDiagnosticForNode(node,
21242126
getStrictModeIdentifierMessage(node), declarationNameToString(node)));
21252127
}
2128+
else if (node.originalKeywordKind === SyntaxKind.AwaitKeyword) {
2129+
if (isExternalModule(file) && isInTopLevelContext(node)) {
2130+
file.bindDiagnostics.push(createDiagnosticForNode(node,
2131+
Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module,
2132+
declarationNameToString(node)));
2133+
}
2134+
else if (node.flags & NodeFlags.AwaitContext) {
2135+
file.bindDiagnostics.push(createDiagnosticForNode(node,
2136+
Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here,
2137+
declarationNameToString(node)));
2138+
}
2139+
}
2140+
else if (node.originalKeywordKind === SyntaxKind.YieldKeyword && node.flags & NodeFlags.YieldContext) {
2141+
file.bindDiagnostics.push(createDiagnosticForNode(node,
2142+
Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here,
2143+
declarationNameToString(node)));
2144+
}
21262145
}
21272146
}
21282147

@@ -2423,7 +2442,7 @@ namespace ts {
24232442
if (currentFlow && (isExpression(node) || parent.kind === SyntaxKind.ShorthandPropertyAssignment)) {
24242443
node.flowNode = currentFlow;
24252444
}
2426-
return checkStrictModeIdentifier(<Identifier>node);
2445+
return checkContextualIdentifier(<Identifier>node);
24272446
case SyntaxKind.SuperKeyword:
24282447
node.flowNode = currentFlow;
24292448
break;
@@ -2865,8 +2884,7 @@ namespace ts {
28652884

28662885
function addLateBoundAssignmentDeclarationToSymbol(node: BinaryExpression | DynamicNamedDeclaration, symbol: Symbol | undefined) {
28672886
if (symbol) {
2868-
const members = symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = createMap());
2869-
members.set("" + getNodeId(node), node);
2887+
(symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = new Map())).set(getNodeId(node), node);
28702888
}
28712889
}
28722890

0 commit comments

Comments
 (0)