Skip to content

Commit 03e38a5

Browse files
committed
2 parents c021ed5 + ac6224d commit 03e38a5

2,092 files changed

Lines changed: 41374 additions & 15922 deletions

File tree

Some content is hidden

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

Jakefile.js

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ var harnessSources = harnessCoreSources.concat([
150150
"reuseProgramStructure.ts",
151151
"cachingInServerLSHost.ts",
152152
"moduleResolution.ts",
153-
"tsconfigParsing.ts"
153+
"tsconfigParsing.ts",
154+
"commandLineParsing.ts",
155+
"convertCompilerOptionsFromJson.ts",
156+
"convertTypingOptionsFromJson.ts"
154157
].map(function (f) {
155158
return path.join(unittestsDirectory, f);
156159
})).concat([
@@ -162,18 +165,47 @@ var harnessSources = harnessCoreSources.concat([
162165
return path.join(serverDirectory, f);
163166
}));
164167

165-
var librarySourceMap = [
166-
{ target: "lib.core.d.ts", sources: ["header.d.ts", "core.d.ts"] },
167-
{ target: "lib.dom.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "dom.generated.d.ts"], },
168-
{ target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "webworker.generated.d.ts"], },
169-
{ target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], },
170-
{ target: "lib.d.ts", sources: ["header.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], },
171-
{ target: "lib.core.es6.d.ts", sources: ["header.d.ts", "core.d.ts", "es6.d.ts"]},
172-
{ target: "lib.es6.d.ts", sources: ["header.d.ts", "es6.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] },
173-
{ target: "lib.core.es7.d.ts", sources: ["header.d.ts", "core.d.ts", "es6.d.ts", "es7.d.ts"]},
174-
{ target: "lib.es7.d.ts", sources: ["header.d.ts", "es6.d.ts", "es7.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] }
168+
var es2015LibrarySources = [
169+
"es2015.core.d.ts",
170+
"es2015.collection.d.ts",
171+
"es2015.generator.d.ts",
172+
"es2015.iterable.d.ts",
173+
"es2015.promise.d.ts",
174+
"es2015.proxy.d.ts",
175+
"es2015.reflect.d.ts",
176+
"es2015.symbol.d.ts",
177+
"es2015.symbol.wellknown.d.ts",
175178
];
176179

180+
var es2015LibrarySourceMap = es2015LibrarySources.map(function(source) {
181+
return { target: "lib." + source, sources: ["header.d.ts", source] };
182+
});
183+
184+
var es2016LibrarySource = [ "es2016.array.include.d.ts" ];
185+
186+
var es2016LibrarySourceMap = es2016LibrarySource.map(function(source) {
187+
return { target: "lib." + source, sources: ["header.d.ts", source] };
188+
})
189+
190+
var hostsLibrarySources = ["dom.generated.d.ts", "webworker.importscripts.d.ts", "scripthost.d.ts"]
191+
192+
var librarySourceMap = [
193+
// Host library
194+
{ target: "lib.dom.d.ts", sources: ["header.d.ts", "dom.generated.d.ts"], },
195+
{ target: "lib.dom.iterable.d.ts", sources: ["header.d.ts", "dom.iterable.d.ts"], },
196+
{ target: "lib.webworker.d.ts", sources: ["header.d.ts", "webworker.generated.d.ts"], },
197+
{ target: "lib.scripthost.d.ts", sources: ["header.d.ts", "scripthost.d.ts"], },
198+
199+
// JavaScript library
200+
{ target: "lib.es5.d.ts", sources: ["header.d.ts", "es5.d.ts"] },
201+
{ target: "lib.es2015.d.ts", sources: ["header.d.ts", "es2015.d.ts"] },
202+
{ target: "lib.es2016.d.ts", sources: ["header.d.ts", "es2016.d.ts"] },
203+
204+
// JavaScript + all host library
205+
{ target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources), },
206+
{ target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources), },
207+
].concat(es2015LibrarySourceMap, es2016LibrarySourceMap);
208+
177209
var libraryTargets = librarySourceMap.map(function (f) {
178210
return path.join(builtLocalDirectory, f.target);
179211
});
@@ -652,7 +684,7 @@ function deleteTemporaryProjectOutput() {
652684
}
653685
}
654686

655-
function runConsoleTests(defaultReporter, defaultSubsets, postLint) {
687+
function runConsoleTests(defaultReporter, defaultSubsets) {
656688
cleanTestDirs();
657689
var debug = process.env.debug || process.env.d;
658690
tests = process.env.test || process.env.tests || process.env.t;
@@ -685,13 +717,13 @@ function runConsoleTests(defaultReporter, defaultSubsets, postLint) {
685717
subsetRegexes = subsets.map(function (sub) { return "^" + sub + ".*$"; });
686718
subsetRegexes.push("^(?!" + subsets.join("|") + ").*$");
687719
}
688-
subsetRegexes.forEach(function (subsetRegex) {
720+
subsetRegexes.forEach(function (subsetRegex, i) {
689721
tests = subsetRegex ? ' -g "' + subsetRegex + '"' : '';
690722
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
691723
console.log(cmd);
692724
exec(cmd, function () {
693725
deleteTemporaryProjectOutput();
694-
if (postLint) {
726+
if (i === 0) {
695727
var lint = jake.Task['lint'];
696728
lint.addListener('complete', function () {
697729
complete();
@@ -713,7 +745,7 @@ task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], functio
713745

714746
desc("Runs the tests using the built run.js file. Optional arguments are: t[ests]=regex r[eporter]=[list|spec|json|<more>] d[ebug]=true color[s]=false.");
715747
task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
716-
runConsoleTests('mocha-fivemat-progress-reporter', [], /*postLint*/ true);
748+
runConsoleTests('mocha-fivemat-progress-reporter', []);
717749
}, {async: true});
718750

719751
desc("Generates code coverage data via instanbul");
@@ -927,6 +959,7 @@ var servicesLintTargets = [
927959
"patternMatcher.ts",
928960
"services.ts",
929961
"shims.ts",
962+
"jsTyping.ts"
930963
].map(function (s) {
931964
return path.join(servicesDirectory, s);
932965
});

scripts/ior.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,11 @@ module Commands {
7676
fs.mkdirSync(directoryPath);
7777
}
7878
}
79+
function normalizeSlashes(path: string): string {
80+
return path.replace(/\\/g, "/");
81+
}
7982
function transalatePath(outputFolder:string, path: string): string {
80-
return outputFolder + directorySeparator + path.replace(":", "");
83+
return normalizeSlashes(outputFolder + directorySeparator + path.replace(":", ""));
8184
}
8285
function fileExists(path: string): boolean {
8386
return fs.existsSync(path);
@@ -86,7 +89,7 @@ module Commands {
8689
var filename = transalatePath(outputFolder, f.path);
8790
ensureDirectoriesExist(getDirectoryPath(filename));
8891
console.log("writing filename: " + filename);
89-
fs.writeFile(filename, f.result.contents, (err) => { });
92+
fs.writeFileSync(filename, f.result.contents);
9093
});
9194

9295
console.log("Command: tsc ");

src/compiler/binder.ts

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ namespace ts {
122122
let hasAsyncFunctions: boolean;
123123
let hasDecorators: boolean;
124124
let hasParameterDecorators: boolean;
125+
let hasJsxSpreadAttribute: boolean;
125126

126127
// If this file is an external module, then it is automatically in strict-mode according to
127128
// ES6. If it is not an external module, then we'll determine if it is in strict mode or
@@ -161,6 +162,7 @@ namespace ts {
161162
hasAsyncFunctions = false;
162163
hasDecorators = false;
163164
hasParameterDecorators = false;
165+
hasJsxSpreadAttribute = false;
164166
}
165167

166168
return bindSourceFile;
@@ -279,6 +281,7 @@ namespace ts {
279281
Debug.assert(!hasDynamicName(node));
280282

281283
const isDefaultExport = node.flags & NodeFlags.Default;
284+
282285
// The exported symbol for an export default function/class node is always named "default"
283286
const name = isDefaultExport && parent ? "default" : getDeclarationName(node);
284287

@@ -497,6 +500,9 @@ namespace ts {
497500
if (hasAsyncFunctions) {
498501
flags |= NodeFlags.HasAsyncFunctions;
499502
}
503+
if (hasJsxSpreadAttribute) {
504+
flags |= NodeFlags.HasJsxSpreadAttribute;
505+
}
500506
}
501507

502508
node.flags = flags;
@@ -708,10 +714,14 @@ namespace ts {
708714
function bindCaseBlock(n: CaseBlock): void {
709715
const startState = currentReachabilityState;
710716

711-
for (const clause of n.clauses) {
717+
for (let i = 0; i < n.clauses.length; i++) {
718+
const clause = n.clauses[i];
712719
currentReachabilityState = startState;
713720
bind(clause);
714-
if (clause.statements.length && currentReachabilityState === Reachability.Reachable && options.noFallthroughCasesInSwitch) {
721+
if (clause.statements.length &&
722+
i !== n.clauses.length - 1 && // allow fallthrough from the last case
723+
currentReachabilityState === Reachability.Reachable &&
724+
options.noFallthroughCasesInSwitch) {
715725
errorOnFirstToken(clause, Diagnostics.Fallthrough_case_in_switch);
716726
}
717727
}
@@ -749,6 +759,7 @@ namespace ts {
749759
case SyntaxKind.GetAccessor:
750760
case SyntaxKind.SetAccessor:
751761
case SyntaxKind.FunctionType:
762+
case SyntaxKind.JSDocFunctionType:
752763
case SyntaxKind.ConstructorType:
753764
case SyntaxKind.FunctionExpression:
754765
case SyntaxKind.ArrowFunction:
@@ -896,7 +907,12 @@ namespace ts {
896907
if (node.flags & NodeFlags.Export) {
897908
errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
898909
}
899-
declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes);
910+
if (isExternalModuleAugmentation(node)) {
911+
declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes);
912+
}
913+
else {
914+
declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes);
915+
}
900916
}
901917
else {
902918
const state = getModuleInstanceState(node);
@@ -1221,7 +1237,7 @@ namespace ts {
12211237

12221238
// Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the
12231239
// string to contain unicode escapes (as per ES5).
1224-
return nodeText === "\"use strict\"" || nodeText === "'use strict'";
1240+
return nodeText === '"use strict"' || nodeText === "'use strict'";
12251241
}
12261242

12271243
function bindWorker(node: Node) {
@@ -1287,6 +1303,10 @@ namespace ts {
12871303
case SyntaxKind.EnumMember:
12881304
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes);
12891305

1306+
case SyntaxKind.JsxSpreadAttribute:
1307+
hasJsxSpreadAttribute = true;
1308+
return;
1309+
12901310
case SyntaxKind.CallSignature:
12911311
case SyntaxKind.ConstructSignature:
12921312
case SyntaxKind.IndexSignature:
@@ -1345,6 +1365,8 @@ namespace ts {
13451365
case SyntaxKind.ImportSpecifier:
13461366
case SyntaxKind.ExportSpecifier:
13471367
return declareSymbolAndAddToSymbolTable(<Declaration>node, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
1368+
case SyntaxKind.GlobalModuleExportDeclaration:
1369+
return bindGlobalModuleExportDeclaration(<GlobalModuleExportDeclaration>node);
13481370
case SyntaxKind.ImportClause:
13491371
return bindImportClause(<ImportClause>node);
13501372
case SyntaxKind.ExportDeclaration:
@@ -1394,6 +1416,33 @@ namespace ts {
13941416
}
13951417
}
13961418

1419+
function bindGlobalModuleExportDeclaration(node: GlobalModuleExportDeclaration) {
1420+
if (node.modifiers && node.modifiers.length) {
1421+
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Modifiers_cannot_appear_here));
1422+
}
1423+
1424+
if (node.parent.kind !== SyntaxKind.SourceFile) {
1425+
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Global_module_exports_may_only_appear_at_top_level));
1426+
return;
1427+
}
1428+
else {
1429+
const parent = node.parent as SourceFile;
1430+
1431+
if (!isExternalModule(parent)) {
1432+
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Global_module_exports_may_only_appear_in_module_files));
1433+
return;
1434+
}
1435+
1436+
if (!parent.isDeclarationFile) {
1437+
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Global_module_exports_may_only_appear_in_declaration_files));
1438+
return;
1439+
}
1440+
}
1441+
1442+
file.symbol.globalExports = file.symbol.globalExports || {};
1443+
declareSymbol(file.symbol.globalExports, file.symbol, node, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
1444+
}
1445+
13971446
function bindExportDeclaration(node: ExportDeclaration) {
13981447
if (!container.symbol || !container.symbol.exports) {
13991448
// Export * in some sort of block construct
@@ -1428,7 +1477,7 @@ namespace ts {
14281477
function bindModuleExportsAssignment(node: BinaryExpression) {
14291478
// 'module.exports = expr' assignment
14301479
setCommonJsModuleIndicator(node);
1431-
bindExportAssignment(node);
1480+
declareSymbol(file.symbol.exports, file.symbol, node, SymbolFlags.Property | SymbolFlags.Export | SymbolFlags.ValueModule, SymbolFlags.None);
14321481
}
14331482

14341483
function bindThisPropertyAssignment(node: BinaryExpression) {

0 commit comments

Comments
 (0)