Skip to content

Commit f235bf7

Browse files
authored
[Transforms] Merge master 06/06/2016 (#8991)
* Remove check narrowing only certain types, add test showing issues with this * string literal case test * Reconcile fix with CFA work * Defaultable -> NotNarrowable to align with use * Missed a defaultable in comments * Add test for narrowing to unions of string literals * Rewrite isInStringLiteral to accomodate for unterminated strings * Refactor signatureHelp to expose helper functions * Add support for completion in string literals * Remove unused check * Use const instead of let * Fix error * Formatting changes * Use shorthand properties * Add failing test for #8738 * Sort baseline reference identifier by name * Detects assignment to internal module export clause, fixes #8738 * add SharedArrayBuffer fix * Factor out assignment op check * Add test for composite assignment * Factor out the behaviour and handles x++ and ++x * Handles ES3 default as identifier name * Fix missing else statement * isNameOfExportedDeclarationInNonES6Module * Reorder options alphabetically * Mark diagnostics, and skipDefaultLibCheck as internal * Allow an import of "foo.js" to be matched by a file "foo.ts" * Improve loadModuleFromFile code * Respond to PR comments * Respond to more PR comments * Fix test * Actually merge from master * Revert to old tryLoad implementation * Run fixupParentReferences when parsing isolated jsDocComment * initial revision of unit test support for project system in tsserver * Allow wildcard ("*") patterns in ambient module declarations * Add non-widening forms of null and undefined * Create separate control flows for property declarations with initializers * Add regression test * Allow trailing commas in function parameter and argument lists * Add tests * Remove unused variable * Add null check and CR feedback * Support shorthand ambient module declarations * Revert "Merge pull request #7235 from weswigham/narrow-all-types" This reverts commit ef0f6c8, reversing changes made to 9f087cb. * reuse the fixupParentReferences function * Improve typing of && operator with --strictNullChecks * Add test * Respond to PR comments * Respond to PR comments * Add merging tests * Use a function `stringify` to simplify calls to `JSON.stringify(xyz, undefined, 2)` * Update tests * Fix mistake * Include indent in navigation bar protocol Previously navbar01 test had indents when run in the browser but not when run from node. Now they run the same. * Remove unnecessary restrictions in property access narrowing * Fix fourslash test * Add regression test * Consider property declarations to be control flow containers * Adding regression test * Remove restriction on --target es5 and --module es6 * change type definition for Object.create * Fix signature help * Add "implicit any" warning for shorthand ambient modules * Remove trailing whitespace * Support using string values in enums for CompilerOptions in transpile methods * Remove trailing whitespace in jakefile * Make `jake runtests-browser` support test regexes with spaces For example: `jake runtests-browser t="transpile .js files"` now works. * Add another test * factor out isJsxOrTsxExtension * Move to a conformance test * Revert "Revert "Merge pull request #7235 from weswigham/narrow-all-types"" This reverts commit fc3e040. * Use inclusive flag, as originally done, but include almost everything * Add additional tests * Respond to PR comments * Fix typo * add tests for tsserver project system * Fix test * Allow case comparison to undefined and null in strict null checking mode * Remove incorrectly added tests * check if moduleResolution when verifying that program can be reused * more tests for module resolution change and exclude * Fix linting issues * Merge JSDoc of assignments from function expressions * Allow nested assignments in type guards * Add tests * Improve order of parameter's merged jsdoc * Force LF newlines for LKG builds/non debug builds Fixes 6630 * Create intersection types in type guards for unrelated types * Split commentsFunction test into expr/decl And renumber. * Remove TODO comments * Accept new baselines * Add tests * Remove comments * Fix test helper * Recognize relative path using in outDir property (#9025) * Recognize relative path using in outDir property * Add projects tests * Add project .json files * Update baselines * Add comments * Add test case The test passes in 1.8 and fails in master. * Return trace when exception happens * Remove Long-Done TODO AFAIK, the harness sources have been concatenated into `run.js` for as long as I've known. This stops executing them twice (and in turn makes debugging tests much easier, since you no longer have to debug into eval'd code). * Allow primitive type guards with typeof on right Previously, only type guards of the form `typeof x === 'string'` were allowed. Now you can write `'string' === typeof x`. * Primitive type guards are now order independent * Fix comments in tests * Add handleing for classes * Add more tests for target=es5 module=es6 * addExportToArgumentListKind * Accept baseline * Add more tests * wip-fixing transforms * Adds progress indicators to the runtests-parallel build task. * Fixed typo * Fix comment * Add test for out-of-range error * Use proper method of not resolving alias * Fix module loading error (commandLineOptions_stringToEnum would be undefined if optionDeclarations wasn't loaded yet) * Port 8739 * Update tests * Update baselines * Contextually type return statement in async function * Remove stale files * Undo change * Improve perf * Improve tests * Fix sourcemaps for debugging tests * Allow --sourceRoot with --inlineSources option Fixes #8445 * this in parameter initializers resolves to class Accept baselines now that the test passes. * Add tests for more kinds of import/export * Fix7334 Disallow async in functionExpression and ArrowFunction (#9062) * Error when using async modifier in function-expression and arrow-function when target es5 * Add tests and baselines * Resolve function-this in parameter initialisers when explicitly provided * Allow null/undefined guard with null/undefined on left Also add a test with baselines. * Code review comments * Update more diagnostic messages ES6->2015 Fix #8996 CC @mhegazy. * Fixes an issue with runtests-parallel when global mocha is not installed. * Update LKG * Add tests * fix baselines * Recommend runtests-parallel in CONTRIBUTING * Only inlineSourceMap when debugging through jake-browser (#9080) * Only inlineSourceMap when debugging through jake-browser * Address PR: fix typo in opt's property * Manually port tests from PR 8470 * minor fix: add missing return clause * Support using string values in enums for CompilerOptions in transpile methods * Support using string values in enums for CompilerOptions in transpile methods # Conflicts: # tests/cases/unittests/transpile.ts * Fix test helper * Add test for out-of-range error * Fix module loading error (commandLineOptions_stringToEnum would be undefined if optionDeclarations wasn't loaded yet) * Use camel-case instead of snake-case (#9134) * Manually add tests for PR 8988 * Allow wildcard ("*") patterns in ambient module declarations * Respond to PR comments * Add another test * Improve perf * Improve tests * Update baseline from merging with master * Address PR comment * Update baseline * Refactor how we retrieve binding-name cache in module transformer * Temporary accept so we get a clean run-tests result
1 parent d147eed commit f235bf7

File tree

406 files changed

+283319
-272615
lines changed

Some content is hidden

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

406 files changed

+283319
-272615
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ tests/webhost/*.d.ts
3636
tests/webhost/webtsc.js
3737
tests/cases/**/*.js
3838
tests/cases/**/*.js.map
39-
tests/cases/**/*.d.ts
4039
*.config
4140
scripts/debug.bat
4241
scripts/run.bat
@@ -51,3 +50,4 @@ internal/
5150
**/.vs
5251
**/.vscode
5352
!**/.vscode/tasks.json
53+
!tests/cases/projects/projectOption/**/node_modules

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ These two files represent the DOM typings and are auto-generated. To make any mo
9191

9292
## Running the Tests
9393

94-
To run all tests, invoke the `runtests` target using jake:
94+
To run all tests, invoke the `runtests-parallel` target using jake:
9595

9696
```Shell
97-
jake runtests
97+
jake runtests-parallel
9898
```
9999

100100
This run will all tests; to run only a specific subset of tests, use:

Jakefile.js

+65-54
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var os = require("os");
55
var path = require("path");
66
var child_process = require("child_process");
77
var Linter = require("tslint");
8+
var runTestsInParallel = require("./scripts/mocha-parallel").runTestsInParallel;
89

910
// Variables
1011
var compilerDirectory = "src/compiler/";
@@ -212,7 +213,10 @@ var es2016LibrarySourceMap = es2016LibrarySource.map(function (source) {
212213
return { target: "lib." + source, sources: ["header.d.ts", source] };
213214
});
214215

215-
var es2017LibrarySource = ["es2017.object.d.ts"];
216+
var es2017LibrarySource = [
217+
"es2017.object.d.ts",
218+
"es2017.sharedmemory.d.ts"
219+
];
216220

217221
var es2017LibrarySourceMap = es2017LibrarySource.map(function (source) {
218222
return { target: "lib." + source, sources: ["header.d.ts", source] };
@@ -296,6 +300,7 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
296300
* @param {boolean} opts.noResolve: true if compiler should not include non-rooted files in compilation
297301
* @param {boolean} opts.stripInternal: true if compiler should remove declarations marked as @internal
298302
* @param {boolean} opts.noMapRoot: true if compiler omit mapRoot option
303+
* @param {boolean} opts.inlineSourceMap: true if compiler should inline sourceMap
299304
* @param callback: a function to execute after the compilation process ends
300305
*/
301306
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts, callback) {
@@ -337,10 +342,16 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
337342
}
338343

339344
if (useDebugMode) {
340-
options += " -sourcemap";
341-
if (!opts.noMapRoot) {
342-
options += " -mapRoot file:///" + path.resolve(path.dirname(outFile));
345+
if (opts.inlineSourceMap) {
346+
options += " --inlineSourceMap --inlineSources";
347+
} else {
348+
options += " -sourcemap";
349+
if (!opts.noMapRoot) {
350+
options += " -mapRoot file:///" + path.resolve(path.dirname(outFile));
351+
}
343352
}
353+
} else {
354+
options += " --newLine LF";
344355
}
345356

346357
if (opts.stripInternal) {
@@ -517,7 +528,13 @@ var nodeStandaloneDefinitionsFile = path.join(builtLocalDirectory, "typescript_s
517528
compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources),
518529
/*prefixes*/ [copyright],
519530
/*useBuiltCompiler*/ true,
520-
{ noOutFile: false, generateDeclarations: true, preserveConstEnums: true, keepComments: true, noResolve: false, stripInternal: true },
531+
/*opts*/ { noOutFile: false,
532+
generateDeclarations: true,
533+
preserveConstEnums: true,
534+
keepComments: true,
535+
noResolve: false,
536+
stripInternal: true
537+
},
521538
/*callback*/ function () {
522539
jake.cpR(servicesFile, nodePackageFile, {silent: true});
523540

@@ -540,16 +557,21 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
540557
fs.writeFileSync(nodeStandaloneDefinitionsFile, nodeStandaloneDefinitionsFileContents);
541558
});
542559

543-
compileFile(servicesFileInBrowserTest, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources),
544-
/*prefixes*/ [copyright],
545-
/*useBuiltCompiler*/ true,
546-
{ noOutFile: false, generateDeclarations: true, preserveConstEnums: true, keepComments: true, noResolve: false, stripInternal: true, noMapRoot: true },
547-
/*callback*/ function () {
548-
var content = fs.readFileSync(servicesFileInBrowserTest).toString();
549-
var i = content.lastIndexOf("\n");
550-
fs.writeFileSync(servicesFileInBrowserTest, content.substring(0, i) + "\r\n//# sourceURL=../built/local/typeScriptServices.js" + content.substring(i));
551-
});
552-
560+
compileFile(
561+
servicesFileInBrowserTest,
562+
servicesSources,
563+
[builtLocalDirectory, copyright].concat(servicesSources),
564+
/*prefixes*/ [copyright],
565+
/*useBuiltCompiler*/ true,
566+
{ noOutFile: false,
567+
generateDeclarations: true,
568+
preserveConstEnums: true,
569+
keepComments: true,
570+
noResolve: false,
571+
stripInternal: true,
572+
noMapRoot: true,
573+
inlineSourceMap: true
574+
});
553575

554576
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
555577
compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true);
@@ -650,7 +672,13 @@ directory(builtLocalDirectory);
650672

651673
// Task to build the tests infrastructure using the built compiler
652674
var run = path.join(builtLocalDirectory, "run.js");
653-
compileFile(run, harnessSources, [builtLocalDirectory, tscFile].concat(libraryTargets).concat(harnessSources), [], /*useBuiltCompiler:*/ true);
675+
compileFile(
676+
/*outFile*/ run,
677+
/*source*/ harnessSources,
678+
/*prereqs*/ [builtLocalDirectory, tscFile].concat(libraryTargets).concat(harnessSources),
679+
/*prefixes*/ [],
680+
/*useBuiltCompiler:*/ true,
681+
/*opts*/ { inlineSourceMap: true });
654682

655683
var internalTests = "internal/";
656684

@@ -774,51 +802,34 @@ function runConsoleTests(defaultReporter, runInParallel) {
774802
tests = tests ? ' -g "' + tests + '"' : '';
775803
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
776804
console.log(cmd);
805+
806+
var savedNodeEnv = process.env.NODE_ENV;
807+
process.env.NODE_ENV = "development";
777808
exec(cmd, function () {
809+
process.env.NODE_ENV = savedNodeEnv;
778810
runLinter();
779811
finish();
780812
}, function(e, status) {
813+
process.env.NODE_ENV = savedNodeEnv;
781814
finish(status);
782815
});
783816

784817
}
785818
else {
786-
// run task to load all tests and partition them between workers
787-
var cmd = "mocha " + " -R min " + colors + run;
788-
console.log(cmd);
789-
exec(cmd, function() {
790-
// read all configuration files and spawn a worker for every config
791-
var configFiles = fs.readdirSync(taskConfigsFolder);
792-
var counter = configFiles.length;
793-
var firstErrorStatus;
794-
// schedule work for chunks
795-
configFiles.forEach(function (f) {
796-
var configPath = path.join(taskConfigsFolder, f);
797-
var workerCmd = "mocha" + " -t " + testTimeout + " -R " + reporter + " " + colors + " " + run + " --config='" + configPath + "'";
798-
console.log(workerCmd);
799-
exec(workerCmd, finishWorker, finishWorker)
800-
});
801-
802-
function finishWorker(e, errorStatus) {
803-
counter--;
804-
if (firstErrorStatus === undefined && errorStatus !== undefined) {
805-
firstErrorStatus = errorStatus;
806-
}
807-
if (counter !== 0) {
808-
complete();
809-
}
810-
else {
811-
// last worker clean everything and runs linter in case if there were no errors
812-
deleteTemporaryProjectOutput();
813-
jake.rmRf(taskConfigsFolder);
814-
if (firstErrorStatus === undefined) {
815-
runLinter();
816-
complete();
817-
}
818-
else {
819-
failWithStatus(firstErrorStatus);
820-
}
821-
}
819+
var savedNodeEnv = process.env.NODE_ENV;
820+
process.env.NODE_ENV = "development";
821+
runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: colors === " --no-colors " }, function (err) {
822+
process.env.NODE_ENV = savedNodeEnv;
823+
824+
// last worker clean everything and runs linter in case if there were no errors
825+
deleteTemporaryProjectOutput();
826+
jake.rmRf(taskConfigsFolder);
827+
if (err) {
828+
fail(err);
829+
}
830+
else {
831+
runLinter();
832+
complete();
822833
}
823834
});
824835
}
@@ -873,7 +884,7 @@ compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile
873884

874885
desc("Runs browserify on run.js to produce a file suitable for running tests in the browser");
875886
task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function() {
876-
var cmd = 'browserify built/local/run.js -t ./scripts/browserify-optional -o built/local/bundle.js';
887+
var cmd = 'browserify built/local/run.js -t ./scripts/browserify-optional -d -o built/local/bundle.js';
877888
exec(cmd);
878889
}, {async: true});
879890

@@ -894,7 +905,7 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFi
894905
}
895906

896907
tests = tests ? tests : '';
897-
var cmd = host + " tests/webTestServer.js " + port + " " + browser + " " + tests;
908+
var cmd = host + " tests/webTestServer.js " + port + " " + browser + " " + JSON.stringify(tests);
898909
console.log(cmd);
899910
exec(cmd);
900911
}, {async: true});

lib/lib.d.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,24 @@ interface ObjectConstructor {
152152
*/
153153
getOwnPropertyNames(o: any): string[];
154154

155+
/**
156+
* Creates an object that has null prototype.
157+
* @param o Object to use as a prototype. May be null
158+
*/
159+
create(o: null): any;
160+
161+
/**
162+
* Creates an object that has the specified prototype, and that optionally contains specified properties.
163+
* @param o Object to use as a prototype. May be null
164+
*/
165+
create<T>(o: T): T;
166+
155167
/**
156168
* Creates an object that has the specified prototype, and that optionally contains specified properties.
157169
* @param o Object to use as a prototype. May be null
158170
* @param properties JavaScript object that contains one or more property descriptors.
159171
*/
160-
create(o: any, properties?: PropertyDescriptorMap): any;
172+
create(o: any, properties: PropertyDescriptorMap): any;
161173

162174
/**
163175
* Adds a property to an object, or modifies attributes of an existing property.

lib/lib.es2017.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ and limitations under the License.
1515

1616
/// <reference no-default-lib="true"/>
1717
/// <reference path="lib.es2016.d.ts" />
18-
/// <reference path="lib.es2017.object.d.ts" />
18+
/// <reference path="lib.es2017.object.d.ts" />
19+
/// <reference path="lib.es2017.sharedmemory.d.ts" />

lib/lib.es2017.sharedmemory.d.ts

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*! *****************************************************************************
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4+
this file except in compliance with the License. You may obtain a copy of the
5+
License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10+
MERCHANTABLITY OR NON-INFRINGEMENT.
11+
12+
See the Apache Version 2.0 License for specific language governing permissions
13+
and limitations under the License.
14+
***************************************************************************** */
15+
16+
/// <reference no-default-lib="true"/>
17+
/// <reference path="lib.es2015.symbol.d.ts" />
18+
/// <reference path="lib.es2015.symbol.wellknown.d.ts" />
19+
20+
interface SharedArrayBuffer {
21+
/**
22+
* Read-only. The length of the ArrayBuffer (in bytes).
23+
*/
24+
readonly byteLength: number;
25+
26+
/*
27+
* The SharedArrayBuffer constructor's length property whose value is 1.
28+
*/
29+
length: number;
30+
/**
31+
* Returns a section of an SharedArrayBuffer.
32+
*/
33+
slice(begin:number, end?:number): SharedArrayBuffer;
34+
readonly [Symbol.species]: SharedArrayBuffer;
35+
readonly [Symbol.toStringTag]: "SharedArrayBuffer";
36+
}
37+
38+
interface SharedArrayBufferConstructor {
39+
readonly prototype: SharedArrayBuffer;
40+
new (byteLength: number): SharedArrayBuffer;
41+
}
42+
43+
declare var SharedArrayBuffer: SharedArrayBufferConstructor;

lib/lib.es5.d.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,24 @@ interface ObjectConstructor {
152152
*/
153153
getOwnPropertyNames(o: any): string[];
154154

155+
/**
156+
* Creates an object that has null prototype.
157+
* @param o Object to use as a prototype. May be null
158+
*/
159+
create(o: null): any;
160+
161+
/**
162+
* Creates an object that has the specified prototype, and that optionally contains specified properties.
163+
* @param o Object to use as a prototype. May be null
164+
*/
165+
create<T>(o: T): T;
166+
155167
/**
156168
* Creates an object that has the specified prototype, and that optionally contains specified properties.
157169
* @param o Object to use as a prototype. May be null
158170
* @param properties JavaScript object that contains one or more property descriptors.
159171
*/
160-
create(o: any, properties?: PropertyDescriptorMap): any;
172+
create(o: any, properties: PropertyDescriptorMap): any;
161173

162174
/**
163175
* Adds a property to an object, or modifies attributes of an existing property.

lib/lib.es6.d.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,24 @@ interface ObjectConstructor {
152152
*/
153153
getOwnPropertyNames(o: any): string[];
154154

155+
/**
156+
* Creates an object that has null prototype.
157+
* @param o Object to use as a prototype. May be null
158+
*/
159+
create(o: null): any;
160+
161+
/**
162+
* Creates an object that has the specified prototype, and that optionally contains specified properties.
163+
* @param o Object to use as a prototype. May be null
164+
*/
165+
create<T>(o: T): T;
166+
155167
/**
156168
* Creates an object that has the specified prototype, and that optionally contains specified properties.
157169
* @param o Object to use as a prototype. May be null
158170
* @param properties JavaScript object that contains one or more property descriptors.
159171
*/
160-
create(o: any, properties?: PropertyDescriptorMap): any;
172+
create(o: any, properties: PropertyDescriptorMap): any;
161173

162174
/**
163175
* Adds a property to an object, or modifies attributes of an existing property.

0 commit comments

Comments
 (0)