mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' of https://github.com/Microsoft/TypeScript into typedefForJsdoc
# Conflicts: # src/services/services.ts # tests/cases/unittests/jsDocParsing.ts
This commit is contained in:
commit
5f9fa69587
627 files changed
+103056
-26922
No files matched your search
+3
-1
@@ -1,10 +1,12 @@
|
||||
built
|
||||
doc
|
||||
internal
|
||||
issue_template.md
|
||||
lib/README.md
|
||||
pull_request_template.md
|
||||
scripts
|
||||
src
|
||||
tests
|
||||
internal
|
||||
tslint.json
|
||||
Jakefile.js
|
||||
.editorconfig
|
||||
|
||||
+69
-49
@@ -160,7 +160,7 @@ var harnessSources = harnessCoreSources.concat([
|
||||
"protocol.d.ts",
|
||||
"session.ts",
|
||||
"client.ts",
|
||||
"editorServices.ts",
|
||||
"editorServices.ts"
|
||||
].map(function (f) {
|
||||
return path.join(serverDirectory, f);
|
||||
}));
|
||||
@@ -174,7 +174,7 @@ var es2015LibrarySources = [
|
||||
"es2015.proxy.d.ts",
|
||||
"es2015.reflect.d.ts",
|
||||
"es2015.symbol.d.ts",
|
||||
"es2015.symbol.wellknown.d.ts",
|
||||
"es2015.symbol.wellknown.d.ts"
|
||||
];
|
||||
|
||||
var es2015LibrarySourceMap = es2015LibrarySources.map(function(source) {
|
||||
@@ -183,28 +183,35 @@ var es2015LibrarySourceMap = es2015LibrarySources.map(function(source) {
|
||||
|
||||
var es2016LibrarySource = [ "es2016.array.include.d.ts" ];
|
||||
|
||||
var es2016LibrarySourceMap = es2016LibrarySource.map(function(source) {
|
||||
var es2016LibrarySourceMap = es2016LibrarySource.map(function (source) {
|
||||
return { target: "lib." + source, sources: ["header.d.ts", source] };
|
||||
})
|
||||
});
|
||||
|
||||
var hostsLibrarySources = ["dom.generated.d.ts", "webworker.importscripts.d.ts", "scripthost.d.ts"]
|
||||
var es2017LibrarySource = ["es2017.object.d.ts"];
|
||||
|
||||
var es2017LibrarySourceMap = es2017LibrarySource.map(function (source) {
|
||||
return { target: "lib." + source, sources: ["header.d.ts", source] };
|
||||
});
|
||||
|
||||
var hostsLibrarySources = ["dom.generated.d.ts", "webworker.importscripts.d.ts", "scripthost.d.ts"];
|
||||
|
||||
var librarySourceMap = [
|
||||
// Host library
|
||||
{ target: "lib.dom.d.ts", sources: ["header.d.ts", "dom.generated.d.ts"], },
|
||||
{ target: "lib.dom.iterable.d.ts", sources: ["header.d.ts", "dom.iterable.d.ts"], },
|
||||
{ target: "lib.webworker.d.ts", sources: ["header.d.ts", "webworker.generated.d.ts"], },
|
||||
{ target: "lib.scripthost.d.ts", sources: ["header.d.ts", "scripthost.d.ts"], },
|
||||
|
||||
{ target: "lib.dom.d.ts", sources: ["header.d.ts", "dom.generated.d.ts"] },
|
||||
{ target: "lib.dom.iterable.d.ts", sources: ["header.d.ts", "dom.iterable.d.ts"] },
|
||||
{ target: "lib.webworker.d.ts", sources: ["header.d.ts", "webworker.generated.d.ts"] },
|
||||
{ target: "lib.scripthost.d.ts", sources: ["header.d.ts", "scripthost.d.ts"] },
|
||||
|
||||
// JavaScript library
|
||||
{ target: "lib.es5.d.ts", sources: ["header.d.ts", "es5.d.ts"] },
|
||||
{ target: "lib.es2015.d.ts", sources: ["header.d.ts", "es2015.d.ts"] },
|
||||
{ target: "lib.es2016.d.ts", sources: ["header.d.ts", "es2016.d.ts"] },
|
||||
{ target: "lib.es2017.d.ts", sources: ["header.d.ts", "es2017.d.ts"] },
|
||||
|
||||
// JavaScript + all host library
|
||||
{ target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources), },
|
||||
{ target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources, "dom.iterable.d.ts"), },
|
||||
].concat(es2015LibrarySourceMap, es2016LibrarySourceMap);
|
||||
{ target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources) },
|
||||
{ target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources, "dom.iterable.d.ts") }
|
||||
].concat(es2015LibrarySourceMap, es2016LibrarySourceMap, es2017LibrarySourceMap);
|
||||
|
||||
var libraryTargets = librarySourceMap.map(function (f) {
|
||||
return path.join(builtLocalDirectory, f.target);
|
||||
@@ -244,7 +251,7 @@ function concatenateFiles(destinationFile, sourceFiles) {
|
||||
}
|
||||
|
||||
var useDebugMode = true;
|
||||
var host = (process.env.TYPESCRIPT_HOST || process.env.host || "node");
|
||||
var host = process.env.TYPESCRIPT_HOST || process.env.host || "node";
|
||||
var compilerFilename = "tsc.js";
|
||||
var LKGCompiler = path.join(LKGDirectory, compilerFilename);
|
||||
var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
|
||||
@@ -293,7 +300,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
|
||||
options += " --out " + outFile;
|
||||
}
|
||||
else {
|
||||
options += " --module commonjs"
|
||||
options += " --module commonjs";
|
||||
}
|
||||
|
||||
if(opts.noResolve) {
|
||||
@@ -308,7 +315,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
|
||||
}
|
||||
|
||||
if (opts.stripInternal) {
|
||||
options += " --stripInternal"
|
||||
options += " --stripInternal";
|
||||
}
|
||||
|
||||
var cmd = host + " " + compilerPath + " " + options + " ";
|
||||
@@ -446,9 +453,9 @@ file(scriptsTsdJson);
|
||||
|
||||
task("tsd-scripts", [scriptsTsdJson], function () {
|
||||
var cmd = "tsd --config " + scriptsTsdJson + " install";
|
||||
console.log(cmd)
|
||||
console.log(cmd);
|
||||
exec(cmd);
|
||||
}, { async: true })
|
||||
}, { async: true });
|
||||
|
||||
var importDefinitelyTypedTestsDirectory = path.join(scriptsDirectory, "importDefinitelyTypedTests");
|
||||
var importDefinitelyTypedTestsJs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.js");
|
||||
@@ -518,9 +525,10 @@ compileFile(servicesFileInBrowserTest, servicesSources,[builtLocalDirectory, cop
|
||||
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
|
||||
compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true);
|
||||
|
||||
var lsslFile = path.join(builtLocalDirectory, "tslssl.js");
|
||||
var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
|
||||
var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
|
||||
compileFile(
|
||||
lsslFile,
|
||||
tsserverLibraryFile,
|
||||
languageServiceLibrarySources,
|
||||
[builtLocalDirectory, copyright].concat(languageServiceLibrarySources),
|
||||
/*prefixes*/ [copyright],
|
||||
@@ -529,7 +537,7 @@ compileFile(
|
||||
|
||||
// Local target to build the language service server library
|
||||
desc("Builds language service server library");
|
||||
task("lssl", [lsslFile]);
|
||||
task("lssl", [tsserverLibraryFile, tsserverLibraryDefinitionFile]);
|
||||
|
||||
// Local target to build the compiler and services
|
||||
desc("Builds the full compiler and services");
|
||||
@@ -588,8 +596,8 @@ task("generate-spec", [specMd]);
|
||||
|
||||
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
|
||||
desc("Makes a new LKG out of the built js files");
|
||||
task("LKG", ["clean", "release", "local"].concat(libraryTargets), function() {
|
||||
var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile].concat(libraryTargets);
|
||||
task("LKG", ["clean", "release", "local", "lssl"].concat(libraryTargets), function() {
|
||||
var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile].concat(libraryTargets);
|
||||
var missingFiles = expectedFiles.filter(function (f) {
|
||||
return !fs.existsSync(f);
|
||||
});
|
||||
@@ -615,7 +623,7 @@ directory(builtLocalDirectory);
|
||||
var run = path.join(builtLocalDirectory, "run.js");
|
||||
compileFile(run, harnessSources, [builtLocalDirectory, tscFile].concat(libraryTargets).concat(harnessSources), [], /*useBuiltCompiler:*/ true);
|
||||
|
||||
var internalTests = "internal/"
|
||||
var internalTests = "internal/";
|
||||
|
||||
var localBaseline = "tests/baselines/local/";
|
||||
var refBaseline = "tests/baselines/reference/";
|
||||
@@ -702,15 +710,16 @@ function runConsoleTests(defaultReporter, defaultSubsets) {
|
||||
testTimeout = 100000;
|
||||
}
|
||||
|
||||
colors = process.env.colors || process.env.color
|
||||
colors = process.env.colors || process.env.color;
|
||||
colors = colors ? ' --no-colors ' : ' --colors ';
|
||||
reporter = process.env.reporter || process.env.r || defaultReporter;
|
||||
var lintFlag = process.env.lint !== 'false';
|
||||
|
||||
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
|
||||
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
|
||||
var subsetRegexes;
|
||||
if(defaultSubsets.length === 0) {
|
||||
subsetRegexes = [tests]
|
||||
subsetRegexes = [tests];
|
||||
}
|
||||
else {
|
||||
var subsets = tests ? tests.split("|") : defaultSubsets;
|
||||
@@ -721,19 +730,20 @@ function runConsoleTests(defaultReporter, defaultSubsets) {
|
||||
tests = subsetRegex ? ' -g "' + subsetRegex + '"' : '';
|
||||
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
|
||||
console.log(cmd);
|
||||
exec(cmd, function () {
|
||||
function finish() {
|
||||
deleteTemporaryProjectOutput();
|
||||
if (i === 0) {
|
||||
complete();
|
||||
}
|
||||
exec(cmd, function () {
|
||||
if (lintFlag && i === 0) {
|
||||
var lint = jake.Task['lint'];
|
||||
lint.addListener('complete', function () {
|
||||
complete();
|
||||
});
|
||||
lint.invoke();
|
||||
}
|
||||
else {
|
||||
complete();
|
||||
}
|
||||
});
|
||||
finish();
|
||||
}, finish);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -743,7 +753,7 @@ task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], functio
|
||||
runConsoleTests('min', ['compiler', 'conformance', 'Projects', 'fourslash']);
|
||||
}, {async: true});
|
||||
|
||||
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.");
|
||||
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 lint=true.");
|
||||
task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
|
||||
runConsoleTests('mocha-fivemat-progress-reporter', []);
|
||||
}, {async: true});
|
||||
@@ -756,8 +766,8 @@ task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
|
||||
}, { async: true });
|
||||
|
||||
// Browser tests
|
||||
var nodeServerOutFile = 'tests/webTestServer.js'
|
||||
var nodeServerInFile = 'tests/webTestServer.ts'
|
||||
var nodeServerOutFile = "tests/webTestServer.js";
|
||||
var nodeServerInFile = "tests/webTestServer.ts";
|
||||
compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, { noOutFile: true });
|
||||
|
||||
desc("Runs browserify on run.js to produce a file suitable for running tests in the browser");
|
||||
@@ -769,7 +779,7 @@ task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function()
|
||||
desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], port=, browser=[chrome|IE]");
|
||||
task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFileInBrowserTest], function() {
|
||||
cleanTestDirs();
|
||||
host = "node"
|
||||
host = "node";
|
||||
port = process.env.port || process.env.p || '8888';
|
||||
browser = process.env.browser || process.env.b || "IE";
|
||||
tests = process.env.test || process.env.tests || process.env.t;
|
||||
@@ -783,13 +793,13 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFi
|
||||
}
|
||||
|
||||
tests = tests ? tests : '';
|
||||
var cmd = host + " tests/webTestServer.js " + port + " " + browser + " " + tests
|
||||
var cmd = host + " tests/webTestServer.js " + port + " " + browser + " " + tests;
|
||||
console.log(cmd);
|
||||
exec(cmd);
|
||||
}, {async: true});
|
||||
|
||||
function getDiffTool() {
|
||||
var program = process.env['DIFF']
|
||||
var program = process.env['DIFF'];
|
||||
if (!program) {
|
||||
fail("Add the 'DIFF' environment variable to the path of the program you want to use.");
|
||||
}
|
||||
@@ -818,11 +828,11 @@ task("tests-debug", ["setDebugMode", "tests"]);
|
||||
// Makes the test results the new baseline
|
||||
desc("Makes the most recent test results the new baseline, overwriting the old baseline");
|
||||
task("baseline-accept", function(hardOrSoft) {
|
||||
if (!hardOrSoft || hardOrSoft == "hard") {
|
||||
if (!hardOrSoft || hardOrSoft === "hard") {
|
||||
jake.rmRf(refBaseline);
|
||||
fs.renameSync(localBaseline, refBaseline);
|
||||
}
|
||||
else if (hardOrSoft == "soft") {
|
||||
else if (hardOrSoft === "soft") {
|
||||
var files = jake.readdirR(localBaseline);
|
||||
for (var i in files) {
|
||||
jake.cpR(files[i], refBaseline);
|
||||
@@ -901,14 +911,14 @@ task("update-sublime", ["local", serverFile], function() {
|
||||
});
|
||||
|
||||
var tslintRuleDir = "scripts/tslint";
|
||||
var tslintRules = ([
|
||||
var tslintRules = [
|
||||
"nextLineRule",
|
||||
"preferConstRule",
|
||||
"booleanTriviaRule",
|
||||
"typeOperatorSpacingRule",
|
||||
"noInOperatorRule",
|
||||
"noIncrementDecrementRule"
|
||||
]);
|
||||
];
|
||||
var tslintRulesFiles = tslintRules.map(function(p) {
|
||||
return path.join(tslintRuleDir, p + ".ts");
|
||||
});
|
||||
@@ -933,7 +943,7 @@ function getLinterOptions() {
|
||||
|
||||
function lintFileContents(options, path, contents) {
|
||||
var ll = new Linter(path, contents, options);
|
||||
console.log("Linting '" + path + "'.")
|
||||
console.log("Linting '" + path + "'.");
|
||||
return ll.lint();
|
||||
}
|
||||
|
||||
@@ -954,6 +964,7 @@ function lintFileAsync(options, path, cb) {
|
||||
|
||||
var servicesLintTargets = [
|
||||
"navigateTo.ts",
|
||||
"navigationBar.ts",
|
||||
"outliningElementsCollector.ts",
|
||||
"patternMatcher.ts",
|
||||
"services.ts",
|
||||
@@ -963,20 +974,29 @@ var servicesLintTargets = [
|
||||
return path.join(servicesDirectory, s);
|
||||
});
|
||||
var lintTargets = compilerSources
|
||||
.concat(harnessCoreSources)
|
||||
.concat(harnessSources)
|
||||
// Other harness sources
|
||||
.concat(["instrumenter.ts"].map(function(f) { return path.join(harnessDirectory, f) }))
|
||||
.concat(serverCoreSources)
|
||||
.concat(tslintRulesFiles)
|
||||
.concat(servicesLintTargets);
|
||||
|
||||
desc("Runs tslint on the compiler sources");
|
||||
|
||||
desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex");
|
||||
task("lint", ["build-rules"], function() {
|
||||
var lintOptions = getLinterOptions();
|
||||
var failed = 0;
|
||||
var fileMatcher = RegExp(process.env.f || process.env.file || process.env.files || "");
|
||||
var done = {};
|
||||
for (var i in lintTargets) {
|
||||
var result = lintFile(lintOptions, lintTargets[i]);
|
||||
if (result.failureCount > 0) {
|
||||
console.log(result.output);
|
||||
failed += result.failureCount;
|
||||
var target = lintTargets[i];
|
||||
if (!done[target] && fileMatcher.test(target)) {
|
||||
var result = lintFile(lintOptions, target);
|
||||
if (result.failureCount > 0) {
|
||||
console.log(result.output);
|
||||
failed += result.failureCount;
|
||||
}
|
||||
done[target] = true;
|
||||
}
|
||||
}
|
||||
if (failed > 0) {
|
||||
|
||||
Vendored
+1283
-1285
File diff suppressed because it is too large.
Load diff
Vendored
+477
-479
File diff suppressed because it is too large.
Load diff
Vendored
+8
-17
@@ -20,13 +20,13 @@ interface Map<K, V> {
|
||||
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
|
||||
get(key: K): V | undefined;
|
||||
has(key: K): boolean;
|
||||
set(key: K, value?: V): Map<K, V>;
|
||||
set(key: K, value?: V): this;
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
new (): Map<any, any>;
|
||||
new <K, V>(): Map<K, V>;
|
||||
new <K, V>(entries?: [K, V][]): Map<K, V>;
|
||||
readonly prototype: Map<any, any>;
|
||||
}
|
||||
declare var Map: MapConstructor;
|
||||
@@ -36,51 +36,42 @@ interface WeakMap<K, V> {
|
||||
delete(key: K): boolean;
|
||||
get(key: K): V | undefined;
|
||||
has(key: K): boolean;
|
||||
set(key: K, value?: V): WeakMap<K, V>;
|
||||
|
||||
set(key: K, value?: V): this;
|
||||
}
|
||||
|
||||
interface WeakMapConstructor {
|
||||
new (): WeakMap<any, any>;
|
||||
new <K, V>(): WeakMap<K, V>;
|
||||
new <K, V>(entries?: [K, V][]): WeakMap<K, V>;
|
||||
readonly prototype: WeakMap<any, any>;
|
||||
}
|
||||
declare var WeakMap: WeakMapConstructor;
|
||||
|
||||
interface Set<T> {
|
||||
add(value: T): Set<T>;
|
||||
add(value: T): this;
|
||||
clear(): void;
|
||||
delete(value: T): boolean;
|
||||
entries(): IterableIterator<[T, T]>;
|
||||
forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
|
||||
has(value: T): boolean;
|
||||
keys(): IterableIterator<T>;
|
||||
readonly size: number;
|
||||
values(): IterableIterator<T>;
|
||||
[Symbol.iterator]():IterableIterator<T>;
|
||||
readonly [Symbol.toStringTag]: "Set";
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
new (): Set<any>;
|
||||
new <T>(): Set<T>;
|
||||
new <T>(iterable: Iterable<T>): Set<T>;
|
||||
new <T>(values?: T[]): Set<T>;
|
||||
readonly prototype: Set<any>;
|
||||
}
|
||||
declare var Set: SetConstructor;
|
||||
|
||||
interface WeakSet<T> {
|
||||
add(value: T): WeakSet<T>;
|
||||
add(value: T): this;
|
||||
clear(): void;
|
||||
delete(value: T): boolean;
|
||||
has(value: T): boolean;
|
||||
readonly [Symbol.toStringTag]: "WeakSet";
|
||||
}
|
||||
|
||||
interface WeakSetConstructor {
|
||||
new (): WeakSet<any>;
|
||||
new <T>(): WeakSet<T>;
|
||||
new <T>(iterable: Iterable<T>): WeakSet<T>;
|
||||
new <T>(values?: T[]): WeakSet<T>;
|
||||
readonly prototype: WeakSet<any>;
|
||||
}
|
||||
declare var WeakSet: WeakSetConstructor;
|
||||
Vendored
+80
-67
@@ -17,48 +17,48 @@ and limitations under the License.
|
||||
declare type PropertyKey = string | number | symbol;
|
||||
|
||||
interface Array<T> {
|
||||
/**
|
||||
* Returns the value of the first element in the array where predicate is true, and undefined
|
||||
/**
|
||||
* Returns the value of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find(predicate: (value: T, index: number, obj: Array<T>) => boolean, thisArg?: any): T | undefined;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: T) => boolean, thisArg?: any): number | undefined;
|
||||
findIndex(predicate: (value: T) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Returns the this object after filling the section identified by start and end with value
|
||||
* @param value value to fill array section with
|
||||
* @param start index to start filling the array at. If start is negative, it is treated as
|
||||
* length+start where length is the length of the array.
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* @param start index to start filling the array at. If start is negative, it is treated as
|
||||
* length+start where length is the length of the array.
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* length+end.
|
||||
*/
|
||||
fill(value: T, start?: number, end?: number): T[];
|
||||
fill(value: T, start?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns the this object after copying a section of the array identified by start and end
|
||||
* to the same array starting at position target
|
||||
* @param target If target is negative, it is treated as length+target where length is the
|
||||
* length of the array.
|
||||
* @param start If start is negative, it is treated as length+start. If end is negative, it
|
||||
* @param target If target is negative, it is treated as length+target where length is the
|
||||
* length of the array.
|
||||
* @param start If start is negative, it is treated as length+start. If end is negative, it
|
||||
* is treated as length+end.
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
*/
|
||||
copyWithin(target: number, start: number, end?: number): T[];
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
}
|
||||
|
||||
interface ArrayConstructor {
|
||||
@@ -130,7 +130,7 @@ interface Math {
|
||||
log1p(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of
|
||||
* Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of
|
||||
* the natural logarithms).
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
@@ -206,14 +206,14 @@ interface Math {
|
||||
interface NumberConstructor {
|
||||
/**
|
||||
* The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1
|
||||
* that is representable as a Number value, which is approximately:
|
||||
* that is representable as a Number value, which is approximately:
|
||||
* 2.2204460492503130808472633361816 x 10−16.
|
||||
*/
|
||||
readonly EPSILON: number;
|
||||
|
||||
/**
|
||||
* Returns true if passed value is finite.
|
||||
* Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a
|
||||
* Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a
|
||||
* number. Only finite values of the type number, result in true.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
@@ -226,7 +226,7 @@ interface NumberConstructor {
|
||||
isInteger(number: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
|
||||
* Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
|
||||
* number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter
|
||||
* to a number. Only values of the type number, that are also NaN, result in true.
|
||||
* @param number A numeric value.
|
||||
@@ -239,30 +239,30 @@ interface NumberConstructor {
|
||||
*/
|
||||
isSafeInteger(number: number): boolean;
|
||||
|
||||
/**
|
||||
* The value of the largest integer n such that n and n + 1 are both exactly representable as
|
||||
* a Number value.
|
||||
/**
|
||||
* The value of the largest integer n such that n and n + 1 are both exactly representable as
|
||||
* a Number value.
|
||||
* The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1.
|
||||
*/
|
||||
readonly MAX_SAFE_INTEGER: number;
|
||||
|
||||
/**
|
||||
* The value of the smallest integer n such that n and n − 1 are both exactly representable as
|
||||
* a Number value.
|
||||
/**
|
||||
* The value of the smallest integer n such that n and n − 1 are both exactly representable as
|
||||
* a Number value.
|
||||
* The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)).
|
||||
*/
|
||||
readonly MIN_SAFE_INTEGER: number;
|
||||
|
||||
/**
|
||||
* Converts a string to a floating-point number.
|
||||
* @param string A string that contains a floating-point number.
|
||||
* Converts a string to a floating-point number.
|
||||
* @param string A string that contains a floating-point number.
|
||||
*/
|
||||
parseFloat(string: string): number;
|
||||
|
||||
/**
|
||||
* Converts A string to an integer.
|
||||
* @param s A string to convert into a number.
|
||||
* @param radix A value between 2 and 36 that specifies the base of the number in numString.
|
||||
* @param radix A value between 2 and 36 that specifies the base of the number in numString.
|
||||
* If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
|
||||
* All other strings are considered decimal.
|
||||
*/
|
||||
@@ -271,12 +271,12 @@ interface NumberConstructor {
|
||||
|
||||
interface Object {
|
||||
/**
|
||||
* Determines whether an object has a property with the specified name.
|
||||
* Determines whether an object has a property with the specified name.
|
||||
* @param v A property name.
|
||||
*/
|
||||
hasOwnProperty(v: PropertyKey): boolean
|
||||
|
||||
/**
|
||||
/**
|
||||
* Determines whether a specified property is enumerable.
|
||||
* @param v A property name.
|
||||
*/
|
||||
@@ -285,7 +285,7 @@ interface Object {
|
||||
|
||||
interface ObjectConstructor {
|
||||
/**
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param source The source object from which to copy properties.
|
||||
@@ -293,7 +293,7 @@ interface ObjectConstructor {
|
||||
assign<T, U>(target: T, source: U): T & U;
|
||||
|
||||
/**
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param source1 The first source object from which to copy properties.
|
||||
@@ -302,7 +302,7 @@ interface ObjectConstructor {
|
||||
assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
|
||||
|
||||
/**
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param source1 The first source object from which to copy properties.
|
||||
@@ -312,7 +312,7 @@ interface ObjectConstructor {
|
||||
assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
|
||||
|
||||
/**
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param sources One or more source objects from which to copy properties
|
||||
@@ -340,17 +340,17 @@ interface ObjectConstructor {
|
||||
setPrototypeOf(o: any, proto: any): any;
|
||||
|
||||
/**
|
||||
* Gets the own property descriptor of the specified object.
|
||||
* An own property descriptor is one that is defined directly on the object and is not
|
||||
* inherited from the object's prototype.
|
||||
* Gets the own property descriptor of the specified object.
|
||||
* An own property descriptor is one that is defined directly on the object and is not
|
||||
* inherited from the object's prototype.
|
||||
* @param o Object that contains the property.
|
||||
* @param p Name of the property.
|
||||
*/
|
||||
getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor;
|
||||
|
||||
/**
|
||||
* Adds a property to an object, or modifies attributes of an existing property.
|
||||
* @param o Object on which to add or modify the property. This can be a native JavaScript
|
||||
* Adds a property to an object, or modifies attributes of an existing property.
|
||||
* @param o Object on which to add or modify the property. This can be a native JavaScript
|
||||
* object (that is, a user-defined object or a built in object) or a DOM object.
|
||||
* @param p The property name.
|
||||
* @param attributes Descriptor for the property. It can be for a data property or an accessor
|
||||
@@ -374,47 +374,60 @@ interface RegExp {
|
||||
*/
|
||||
readonly flags: string;
|
||||
|
||||
/**
|
||||
* Returns a Boolean value indicating the state of the sticky flag (y) used with a regular
|
||||
* expression. Default is false. Read-only.
|
||||
/**
|
||||
* Returns a Boolean value indicating the state of the sticky flag (y) used with a regular
|
||||
* expression. Default is false. Read-only.
|
||||
*/
|
||||
readonly sticky: boolean;
|
||||
|
||||
/**
|
||||
* Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular
|
||||
* expression. Default is false. Read-only.
|
||||
/**
|
||||
* Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular
|
||||
* expression. Default is false. Read-only.
|
||||
*/
|
||||
readonly unicode: boolean;
|
||||
}
|
||||
|
||||
interface RegExpConstructor {
|
||||
new (pattern: RegExp, flags?: string): RegExp;
|
||||
(pattern: RegExp, flags?: string): RegExp;
|
||||
}
|
||||
|
||||
interface String {
|
||||
/**
|
||||
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
|
||||
* value of the UTF-16 encoded code point starting at the string element at position pos in
|
||||
* the String resulting from converting this object to a String.
|
||||
* If there is no element at that position, the result is undefined.
|
||||
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
|
||||
* value of the UTF-16 encoded code point starting at the string element at position pos in
|
||||
* the String resulting from converting this object to a String.
|
||||
* If there is no element at that position, the result is undefined.
|
||||
* If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
|
||||
*/
|
||||
codePointAt(pos: number): number | undefined;
|
||||
|
||||
/**
|
||||
* Returns true if searchString appears as a substring of the result of converting this
|
||||
* object to a String, at one or more positions that are
|
||||
* Returns true if searchString appears as a substring of the result of converting this
|
||||
* object to a String, at one or more positions that are
|
||||
* greater than or equal to position; otherwise, returns false.
|
||||
* @param searchString search string
|
||||
* @param searchString search string
|
||||
* @param position If position is undefined, 0 is assumed, so as to search all of the String.
|
||||
*/
|
||||
includes(searchString: string, position?: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the sequence of elements of searchString converted to a String is the
|
||||
* same as the corresponding elements of this object (converted to a String) starting at
|
||||
* Returns true if the sequence of elements of searchString converted to a String is the
|
||||
* same as the corresponding elements of this object (converted to a String) starting at
|
||||
* endPosition – length(this). Otherwise returns false.
|
||||
*/
|
||||
endsWith(searchString: string, endPosition?: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns the String value result of normalizing the string into the normalization form
|
||||
* Returns the String value result of normalizing the string into the normalization form
|
||||
* named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
|
||||
* @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
|
||||
* is "NFC"
|
||||
*/
|
||||
normalize(form: "NFC" | "NFD" | "NFKC" | "NFKD"): string;
|
||||
|
||||
/**
|
||||
* Returns the String value result of normalizing the string into the normalization form
|
||||
* named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
|
||||
* @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
|
||||
* is "NFC"
|
||||
@@ -422,15 +435,15 @@ interface String {
|
||||
normalize(form?: string): string;
|
||||
|
||||
/**
|
||||
* Returns a String value that is made from count copies appended together. If count is 0,
|
||||
* Returns a String value that is made from count copies appended together. If count is 0,
|
||||
* T is the empty String is returned.
|
||||
* @param count number of copies to append
|
||||
*/
|
||||
repeat(count: number): string;
|
||||
|
||||
/**
|
||||
* Returns true if the sequence of elements of searchString converted to a String is the
|
||||
* same as the corresponding elements of this object (converted to a String) starting at
|
||||
* Returns true if the sequence of elements of searchString converted to a String is the
|
||||
* same as the corresponding elements of this object (converted to a String) starting at
|
||||
* position. Otherwise returns false.
|
||||
*/
|
||||
startsWith(searchString: string, position?: number): boolean;
|
||||
@@ -490,10 +503,10 @@ interface StringConstructor {
|
||||
|
||||
/**
|
||||
* String.raw is intended for use as a tag function of a Tagged Template String. When called
|
||||
* as such the first argument will be a well formed template call site object and the rest
|
||||
* as such the first argument will be a well formed template call site object and the rest
|
||||
* parameter will contain the substitution values.
|
||||
* @param template A well-formed template string call site representation.
|
||||
* @param substitutions A set of substitution values.
|
||||
*/
|
||||
raw(template: TemplateStringsArray, ...substitutions: any[]): string;
|
||||
}
|
||||
}
|
||||
Vendored
+55
-3
@@ -16,9 +16,17 @@ and limitations under the License.
|
||||
/// <reference no-default-lib="true"/>
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A method that returns the default iterator for an object. Called by the semantics of the
|
||||
* for-of statement.
|
||||
*/
|
||||
readonly iterator: symbol;
|
||||
}
|
||||
|
||||
interface IteratorResult<T> {
|
||||
done: boolean;
|
||||
value?: T;
|
||||
value: T;
|
||||
}
|
||||
|
||||
interface Iterator<T> {
|
||||
@@ -27,11 +35,18 @@ interface Iterator<T> {
|
||||
throw?(e?: any): IteratorResult<T>;
|
||||
}
|
||||
|
||||
interface Iterable<T> { }
|
||||
interface Iterable<T> {
|
||||
[Symbol.iterator](): Iterator<T>;
|
||||
}
|
||||
|
||||
interface IterableIterator<T> extends Iterator<T> { }
|
||||
interface IterableIterator<T> extends Iterator<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface Array<T> {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -64,7 +79,13 @@ interface ArrayConstructor {
|
||||
from<T>(iterable: Iterable<T>): Array<T>;
|
||||
}
|
||||
|
||||
interface IArguments {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<any>;
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
[Symbol.iterator](): IterableIterator<[K,V]>;
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
keys(): IterableIterator<K>;
|
||||
values(): IterableIterator<V>;
|
||||
@@ -80,6 +101,23 @@ interface WeakMapConstructor {
|
||||
new <K, V>(iterable: Iterable<[K, V]>): WeakMap<K, V>;
|
||||
}
|
||||
|
||||
interface Set<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
entries(): IterableIterator<[T, T]>;
|
||||
keys(): IterableIterator<T>;
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
new <T>(iterable: Iterable<T>): Set<T>;
|
||||
}
|
||||
|
||||
interface WeakSet<T> { }
|
||||
|
||||
interface WeakSetConstructor {
|
||||
new <T>(iterable: Iterable<T>): WeakSet<T>;
|
||||
}
|
||||
|
||||
interface Promise<T> { }
|
||||
|
||||
interface PromiseConstructor {
|
||||
@@ -104,11 +142,17 @@ declare namespace Reflect {
|
||||
function enumerate(target: any): IterableIterator<any>;
|
||||
}
|
||||
|
||||
interface String {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit integer values. The contents are initialized to 0. If the requested
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int8Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -140,6 +184,7 @@ interface Int8ArrayConstructor {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -171,6 +216,7 @@ interface Uint8ArrayConstructor {
|
||||
* If the requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8ClampedArray {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -205,6 +251,7 @@ interface Uint8ClampedArrayConstructor {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int16Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -238,6 +285,7 @@ interface Int16ArrayConstructor {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint16Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -269,6 +317,7 @@ interface Uint16ArrayConstructor {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -300,6 +349,7 @@ interface Int32ArrayConstructor {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -331,6 +381,7 @@ interface Uint32ArrayConstructor {
|
||||
* of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -362,6 +413,7 @@ interface Float32ArrayConstructor {
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float64Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
|
||||
Vendored
+8
-37
@@ -29,12 +29,6 @@ interface SymbolConstructor {
|
||||
*/
|
||||
readonly isConcatSpreadable: symbol;
|
||||
|
||||
/**
|
||||
* A method that returns the default iterator for an object. Called by the semantics of the
|
||||
* for-of statement.
|
||||
*/
|
||||
readonly iterator: symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that matches the regular expression against a string. Called
|
||||
* by the String.prototype.match method.
|
||||
@@ -89,9 +83,6 @@ interface Symbol {
|
||||
}
|
||||
|
||||
interface Array<T> {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an object whose properties have the value 'true'
|
||||
* when they will be absent when used in a 'with' statement.
|
||||
@@ -132,7 +123,6 @@ interface Date {
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
[Symbol.iterator]():IterableIterator<[K,V]>;
|
||||
readonly [Symbol.toStringTag]: "Map";
|
||||
}
|
||||
|
||||
@@ -140,6 +130,14 @@ interface WeakMap<K, V>{
|
||||
readonly [Symbol.toStringTag]: "WeakMap";
|
||||
}
|
||||
|
||||
interface Set<T> {
|
||||
readonly [Symbol.toStringTag]: "Set";
|
||||
}
|
||||
|
||||
interface WeakSet<T> {
|
||||
readonly [Symbol.toStringTag]: "WeakSet";
|
||||
}
|
||||
|
||||
interface JSON {
|
||||
readonly [Symbol.toStringTag]: "JSON";
|
||||
}
|
||||
@@ -159,21 +157,6 @@ interface GeneratorFunction extends Function {
|
||||
readonly [Symbol.toStringTag]: "GeneratorFunction";
|
||||
}
|
||||
|
||||
interface IArguments {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<any>;
|
||||
}
|
||||
|
||||
interface Iterator<T> { }
|
||||
|
||||
interface Iterable<T> {
|
||||
[Symbol.iterator](): Iterator<T>;
|
||||
}
|
||||
|
||||
interface IterableIterator<T> extends Iterator<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface Math {
|
||||
readonly [Symbol.toStringTag]: "Math";
|
||||
}
|
||||
@@ -239,9 +222,6 @@ interface RegExpConstructor {
|
||||
}
|
||||
|
||||
interface String {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
|
||||
/**
|
||||
* Matches a string an object that supports being matched against, and returns an array containing the results of that search.
|
||||
* @param matcher An object that supports being matched against.
|
||||
@@ -295,7 +275,6 @@ interface DataView {
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int8Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "Int8Array";
|
||||
}
|
||||
|
||||
@@ -304,7 +283,6 @@ interface Int8Array {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "UInt8Array";
|
||||
}
|
||||
|
||||
@@ -313,7 +291,6 @@ interface Uint8Array {
|
||||
* If the requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8ClampedArray {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "Uint8ClampedArray";
|
||||
}
|
||||
|
||||
@@ -322,7 +299,6 @@ interface Uint8ClampedArray {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int16Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "Int16Array";
|
||||
}
|
||||
|
||||
@@ -331,7 +307,6 @@ interface Int16Array {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint16Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "Uint16Array";
|
||||
}
|
||||
|
||||
@@ -340,7 +315,6 @@ interface Uint16Array {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "Int32Array";
|
||||
}
|
||||
|
||||
@@ -349,7 +323,6 @@ interface Int32Array {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "Uint32Array";
|
||||
}
|
||||
|
||||
@@ -358,7 +331,6 @@ interface Uint32Array {
|
||||
* of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "Float32Array";
|
||||
}
|
||||
|
||||
@@ -367,6 +339,5 @@ interface Float32Array {
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float64Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "Float64Array";
|
||||
}
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
/// <reference path="lib.es2016.d.ts" />
|
||||
/// <reference path="lib.es2017.object.d.ts" />
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
interface ObjectConstructor {
|
||||
/**
|
||||
* Returns an array of values of the enumerable properties of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
values<T>(o: { [s: string]: T }): T[];
|
||||
values(o: any): any[];
|
||||
/**
|
||||
* Returns an array of key/values of the enumerable properties of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
entries<T>(o: { [s: string]: T }): [string, T][];
|
||||
entries(o: any): [string, any][];
|
||||
}
|
||||
Vendored
+806
-806
File diff suppressed because it is too large.
Load diff
Vendored
+1449
-1410
File diff suppressed because it is too large.
Load diff
File renamed without changes.
Vendored
+18
-7
@@ -24,6 +24,16 @@ interface EventInit {
|
||||
cancelable?: boolean;
|
||||
}
|
||||
|
||||
interface IDBIndexParameters {
|
||||
multiEntry?: boolean;
|
||||
unique?: boolean;
|
||||
}
|
||||
|
||||
interface IDBObjectStoreParameters {
|
||||
autoIncrement?: boolean;
|
||||
keyPath?: IDBKeyPath;
|
||||
}
|
||||
|
||||
interface EventListener {
|
||||
(evt: Event): void;
|
||||
}
|
||||
@@ -100,12 +110,12 @@ declare var Console: {
|
||||
|
||||
interface Coordinates {
|
||||
readonly accuracy: number;
|
||||
readonly altitude: number;
|
||||
readonly altitudeAccuracy: number;
|
||||
readonly heading: number;
|
||||
readonly altitude: number | null;
|
||||
readonly altitudeAccuracy: number | null;
|
||||
readonly heading: number | null;
|
||||
readonly latitude: number;
|
||||
readonly longitude: number;
|
||||
readonly speed: number;
|
||||
readonly speed: number | null;
|
||||
}
|
||||
|
||||
declare var Coordinates: {
|
||||
@@ -192,7 +202,7 @@ declare var DOMException: {
|
||||
interface DOMStringList {
|
||||
readonly length: number;
|
||||
contains(str: string): boolean;
|
||||
item(index: number): string;
|
||||
item(index: number): string | null;
|
||||
[index: number]: string;
|
||||
}
|
||||
|
||||
@@ -475,7 +485,7 @@ declare var IDBTransaction: {
|
||||
}
|
||||
|
||||
interface IDBVersionChangeEvent extends Event {
|
||||
readonly newVersion: number;
|
||||
readonly newVersion: number | null;
|
||||
readonly oldVersion: number;
|
||||
}
|
||||
|
||||
@@ -728,7 +738,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
|
||||
withCredentials: boolean;
|
||||
abort(): void;
|
||||
getAllResponseHeaders(): string;
|
||||
getResponseHeader(header: string): string;
|
||||
getResponseHeader(header: string): string | null;
|
||||
msCachingEnabled(): boolean;
|
||||
open(method: string, url: string, async?: boolean, user?: string, password?: string): void;
|
||||
overrideMimeType(mime: string): void;
|
||||
@@ -1007,4 +1017,5 @@ declare var console: Console;
|
||||
declare function addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
type IDBKeyPath = string;
|
||||
type IDBValidKey = number | string | Date | IDBArrayKey;
|
||||
+4304
-3482
File diff suppressed because it is too large.
Load diff
+5897
-4657
File diff suppressed because it is too large.
Load diff
Vendored
+8618
File diff suppressed because it is too large.
Load diff
+51467
File diff suppressed because it is too large.
Load diff
Vendored
+216
-165
@@ -160,173 +160,174 @@ declare namespace ts {
|
||||
IsKeyword = 124,
|
||||
ModuleKeyword = 125,
|
||||
NamespaceKeyword = 126,
|
||||
ReadonlyKeyword = 127,
|
||||
RequireKeyword = 128,
|
||||
NumberKeyword = 129,
|
||||
SetKeyword = 130,
|
||||
StringKeyword = 131,
|
||||
SymbolKeyword = 132,
|
||||
TypeKeyword = 133,
|
||||
UndefinedKeyword = 134,
|
||||
FromKeyword = 135,
|
||||
GlobalKeyword = 136,
|
||||
OfKeyword = 137,
|
||||
QualifiedName = 138,
|
||||
ComputedPropertyName = 139,
|
||||
TypeParameter = 140,
|
||||
Parameter = 141,
|
||||
Decorator = 142,
|
||||
PropertySignature = 143,
|
||||
PropertyDeclaration = 144,
|
||||
MethodSignature = 145,
|
||||
MethodDeclaration = 146,
|
||||
Constructor = 147,
|
||||
GetAccessor = 148,
|
||||
SetAccessor = 149,
|
||||
CallSignature = 150,
|
||||
ConstructSignature = 151,
|
||||
IndexSignature = 152,
|
||||
TypePredicate = 153,
|
||||
TypeReference = 154,
|
||||
FunctionType = 155,
|
||||
ConstructorType = 156,
|
||||
TypeQuery = 157,
|
||||
TypeLiteral = 158,
|
||||
ArrayType = 159,
|
||||
TupleType = 160,
|
||||
UnionType = 161,
|
||||
IntersectionType = 162,
|
||||
ParenthesizedType = 163,
|
||||
ThisType = 164,
|
||||
StringLiteralType = 165,
|
||||
ObjectBindingPattern = 166,
|
||||
ArrayBindingPattern = 167,
|
||||
BindingElement = 168,
|
||||
ArrayLiteralExpression = 169,
|
||||
ObjectLiteralExpression = 170,
|
||||
PropertyAccessExpression = 171,
|
||||
ElementAccessExpression = 172,
|
||||
CallExpression = 173,
|
||||
NewExpression = 174,
|
||||
TaggedTemplateExpression = 175,
|
||||
TypeAssertionExpression = 176,
|
||||
ParenthesizedExpression = 177,
|
||||
FunctionExpression = 178,
|
||||
ArrowFunction = 179,
|
||||
DeleteExpression = 180,
|
||||
TypeOfExpression = 181,
|
||||
VoidExpression = 182,
|
||||
AwaitExpression = 183,
|
||||
PrefixUnaryExpression = 184,
|
||||
PostfixUnaryExpression = 185,
|
||||
BinaryExpression = 186,
|
||||
ConditionalExpression = 187,
|
||||
TemplateExpression = 188,
|
||||
YieldExpression = 189,
|
||||
SpreadElementExpression = 190,
|
||||
ClassExpression = 191,
|
||||
OmittedExpression = 192,
|
||||
ExpressionWithTypeArguments = 193,
|
||||
AsExpression = 194,
|
||||
NonNullExpression = 195,
|
||||
TemplateSpan = 196,
|
||||
SemicolonClassElement = 197,
|
||||
Block = 198,
|
||||
VariableStatement = 199,
|
||||
EmptyStatement = 200,
|
||||
ExpressionStatement = 201,
|
||||
IfStatement = 202,
|
||||
DoStatement = 203,
|
||||
WhileStatement = 204,
|
||||
ForStatement = 205,
|
||||
ForInStatement = 206,
|
||||
ForOfStatement = 207,
|
||||
ContinueStatement = 208,
|
||||
BreakStatement = 209,
|
||||
ReturnStatement = 210,
|
||||
WithStatement = 211,
|
||||
SwitchStatement = 212,
|
||||
LabeledStatement = 213,
|
||||
ThrowStatement = 214,
|
||||
TryStatement = 215,
|
||||
DebuggerStatement = 216,
|
||||
VariableDeclaration = 217,
|
||||
VariableDeclarationList = 218,
|
||||
FunctionDeclaration = 219,
|
||||
ClassDeclaration = 220,
|
||||
InterfaceDeclaration = 221,
|
||||
TypeAliasDeclaration = 222,
|
||||
EnumDeclaration = 223,
|
||||
ModuleDeclaration = 224,
|
||||
ModuleBlock = 225,
|
||||
CaseBlock = 226,
|
||||
GlobalModuleExportDeclaration = 227,
|
||||
ImportEqualsDeclaration = 228,
|
||||
ImportDeclaration = 229,
|
||||
ImportClause = 230,
|
||||
NamespaceImport = 231,
|
||||
NamedImports = 232,
|
||||
ImportSpecifier = 233,
|
||||
ExportAssignment = 234,
|
||||
ExportDeclaration = 235,
|
||||
NamedExports = 236,
|
||||
ExportSpecifier = 237,
|
||||
MissingDeclaration = 238,
|
||||
ExternalModuleReference = 239,
|
||||
JsxElement = 240,
|
||||
JsxSelfClosingElement = 241,
|
||||
JsxOpeningElement = 242,
|
||||
JsxText = 243,
|
||||
JsxClosingElement = 244,
|
||||
JsxAttribute = 245,
|
||||
JsxSpreadAttribute = 246,
|
||||
JsxExpression = 247,
|
||||
CaseClause = 248,
|
||||
DefaultClause = 249,
|
||||
HeritageClause = 250,
|
||||
CatchClause = 251,
|
||||
PropertyAssignment = 252,
|
||||
ShorthandPropertyAssignment = 253,
|
||||
EnumMember = 254,
|
||||
SourceFile = 255,
|
||||
JSDocTypeExpression = 256,
|
||||
JSDocAllType = 257,
|
||||
JSDocUnknownType = 258,
|
||||
JSDocArrayType = 259,
|
||||
JSDocUnionType = 260,
|
||||
JSDocTupleType = 261,
|
||||
JSDocNullableType = 262,
|
||||
JSDocNonNullableType = 263,
|
||||
JSDocRecordType = 264,
|
||||
JSDocRecordMember = 265,
|
||||
JSDocTypeReference = 266,
|
||||
JSDocOptionalType = 267,
|
||||
JSDocFunctionType = 268,
|
||||
JSDocVariadicType = 269,
|
||||
JSDocConstructorType = 270,
|
||||
JSDocThisType = 271,
|
||||
JSDocComment = 272,
|
||||
JSDocTag = 273,
|
||||
JSDocParameterTag = 274,
|
||||
JSDocReturnTag = 275,
|
||||
JSDocTypeTag = 276,
|
||||
JSDocTemplateTag = 277,
|
||||
SyntaxList = 278,
|
||||
Count = 279,
|
||||
NeverKeyword = 127,
|
||||
ReadonlyKeyword = 128,
|
||||
RequireKeyword = 129,
|
||||
NumberKeyword = 130,
|
||||
SetKeyword = 131,
|
||||
StringKeyword = 132,
|
||||
SymbolKeyword = 133,
|
||||
TypeKeyword = 134,
|
||||
UndefinedKeyword = 135,
|
||||
FromKeyword = 136,
|
||||
GlobalKeyword = 137,
|
||||
OfKeyword = 138,
|
||||
QualifiedName = 139,
|
||||
ComputedPropertyName = 140,
|
||||
TypeParameter = 141,
|
||||
Parameter = 142,
|
||||
Decorator = 143,
|
||||
PropertySignature = 144,
|
||||
PropertyDeclaration = 145,
|
||||
MethodSignature = 146,
|
||||
MethodDeclaration = 147,
|
||||
Constructor = 148,
|
||||
GetAccessor = 149,
|
||||
SetAccessor = 150,
|
||||
CallSignature = 151,
|
||||
ConstructSignature = 152,
|
||||
IndexSignature = 153,
|
||||
TypePredicate = 154,
|
||||
TypeReference = 155,
|
||||
FunctionType = 156,
|
||||
ConstructorType = 157,
|
||||
TypeQuery = 158,
|
||||
TypeLiteral = 159,
|
||||
ArrayType = 160,
|
||||
TupleType = 161,
|
||||
UnionType = 162,
|
||||
IntersectionType = 163,
|
||||
ParenthesizedType = 164,
|
||||
ThisType = 165,
|
||||
StringLiteralType = 166,
|
||||
ObjectBindingPattern = 167,
|
||||
ArrayBindingPattern = 168,
|
||||
BindingElement = 169,
|
||||
ArrayLiteralExpression = 170,
|
||||
ObjectLiteralExpression = 171,
|
||||
PropertyAccessExpression = 172,
|
||||
ElementAccessExpression = 173,
|
||||
CallExpression = 174,
|
||||
NewExpression = 175,
|
||||
TaggedTemplateExpression = 176,
|
||||
TypeAssertionExpression = 177,
|
||||
ParenthesizedExpression = 178,
|
||||
FunctionExpression = 179,
|
||||
ArrowFunction = 180,
|
||||
DeleteExpression = 181,
|
||||
TypeOfExpression = 182,
|
||||
VoidExpression = 183,
|
||||
AwaitExpression = 184,
|
||||
PrefixUnaryExpression = 185,
|
||||
PostfixUnaryExpression = 186,
|
||||
BinaryExpression = 187,
|
||||
ConditionalExpression = 188,
|
||||
TemplateExpression = 189,
|
||||
YieldExpression = 190,
|
||||
SpreadElementExpression = 191,
|
||||
ClassExpression = 192,
|
||||
OmittedExpression = 193,
|
||||
ExpressionWithTypeArguments = 194,
|
||||
AsExpression = 195,
|
||||
NonNullExpression = 196,
|
||||
TemplateSpan = 197,
|
||||
SemicolonClassElement = 198,
|
||||
Block = 199,
|
||||
VariableStatement = 200,
|
||||
EmptyStatement = 201,
|
||||
ExpressionStatement = 202,
|
||||
IfStatement = 203,
|
||||
DoStatement = 204,
|
||||
WhileStatement = 205,
|
||||
ForStatement = 206,
|
||||
ForInStatement = 207,
|
||||
ForOfStatement = 208,
|
||||
ContinueStatement = 209,
|
||||
BreakStatement = 210,
|
||||
ReturnStatement = 211,
|
||||
WithStatement = 212,
|
||||
SwitchStatement = 213,
|
||||
LabeledStatement = 214,
|
||||
ThrowStatement = 215,
|
||||
TryStatement = 216,
|
||||
DebuggerStatement = 217,
|
||||
VariableDeclaration = 218,
|
||||
VariableDeclarationList = 219,
|
||||
FunctionDeclaration = 220,
|
||||
ClassDeclaration = 221,
|
||||
InterfaceDeclaration = 222,
|
||||
TypeAliasDeclaration = 223,
|
||||
EnumDeclaration = 224,
|
||||
ModuleDeclaration = 225,
|
||||
ModuleBlock = 226,
|
||||
CaseBlock = 227,
|
||||
GlobalModuleExportDeclaration = 228,
|
||||
ImportEqualsDeclaration = 229,
|
||||
ImportDeclaration = 230,
|
||||
ImportClause = 231,
|
||||
NamespaceImport = 232,
|
||||
NamedImports = 233,
|
||||
ImportSpecifier = 234,
|
||||
ExportAssignment = 235,
|
||||
ExportDeclaration = 236,
|
||||
NamedExports = 237,
|
||||
ExportSpecifier = 238,
|
||||
MissingDeclaration = 239,
|
||||
ExternalModuleReference = 240,
|
||||
JsxElement = 241,
|
||||
JsxSelfClosingElement = 242,
|
||||
JsxOpeningElement = 243,
|
||||
JsxText = 244,
|
||||
JsxClosingElement = 245,
|
||||
JsxAttribute = 246,
|
||||
JsxSpreadAttribute = 247,
|
||||
JsxExpression = 248,
|
||||
CaseClause = 249,
|
||||
DefaultClause = 250,
|
||||
HeritageClause = 251,
|
||||
CatchClause = 252,
|
||||
PropertyAssignment = 253,
|
||||
ShorthandPropertyAssignment = 254,
|
||||
EnumMember = 255,
|
||||
SourceFile = 256,
|
||||
JSDocTypeExpression = 257,
|
||||
JSDocAllType = 258,
|
||||
JSDocUnknownType = 259,
|
||||
JSDocArrayType = 260,
|
||||
JSDocUnionType = 261,
|
||||
JSDocTupleType = 262,
|
||||
JSDocNullableType = 263,
|
||||
JSDocNonNullableType = 264,
|
||||
JSDocRecordType = 265,
|
||||
JSDocRecordMember = 266,
|
||||
JSDocTypeReference = 267,
|
||||
JSDocOptionalType = 268,
|
||||
JSDocFunctionType = 269,
|
||||
JSDocVariadicType = 270,
|
||||
JSDocConstructorType = 271,
|
||||
JSDocThisType = 272,
|
||||
JSDocComment = 273,
|
||||
JSDocTag = 274,
|
||||
JSDocParameterTag = 275,
|
||||
JSDocReturnTag = 276,
|
||||
JSDocTypeTag = 277,
|
||||
JSDocTemplateTag = 278,
|
||||
SyntaxList = 279,
|
||||
Count = 280,
|
||||
FirstAssignment = 56,
|
||||
LastAssignment = 68,
|
||||
FirstReservedWord = 70,
|
||||
LastReservedWord = 105,
|
||||
FirstKeyword = 70,
|
||||
LastKeyword = 137,
|
||||
LastKeyword = 138,
|
||||
FirstFutureReservedWord = 106,
|
||||
LastFutureReservedWord = 114,
|
||||
FirstTypeNode = 153,
|
||||
LastTypeNode = 165,
|
||||
FirstTypeNode = 154,
|
||||
LastTypeNode = 166,
|
||||
FirstPunctuation = 15,
|
||||
LastPunctuation = 68,
|
||||
FirstToken = 0,
|
||||
LastToken = 137,
|
||||
LastToken = 138,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 7,
|
||||
FirstLiteralToken = 8,
|
||||
@@ -335,7 +336,7 @@ declare namespace ts {
|
||||
LastTemplateToken = 14,
|
||||
FirstBinaryOperator = 25,
|
||||
LastBinaryOperator = 68,
|
||||
FirstNode = 138,
|
||||
FirstNode = 139,
|
||||
}
|
||||
enum NodeFlags {
|
||||
None = 0,
|
||||
@@ -370,8 +371,9 @@ declare namespace ts {
|
||||
ThisNodeOrAnySubNodesHasError = 268435456,
|
||||
HasAggregatedChildData = 536870912,
|
||||
HasJsxSpreadAttribute = 1073741824,
|
||||
Modifier = 959,
|
||||
Modifier = 1023,
|
||||
AccessibilityModifier = 28,
|
||||
ParameterPropertyModifier = 92,
|
||||
BlockScoped = 3072,
|
||||
ReachabilityCheckFlags = 98304,
|
||||
EmitHelperFlags = 3932160,
|
||||
@@ -405,9 +407,6 @@ declare namespace ts {
|
||||
text: string;
|
||||
originalKeywordKind?: SyntaxKind;
|
||||
}
|
||||
interface TransientIdentifier extends Identifier {
|
||||
resolvedSymbol: Symbol;
|
||||
}
|
||||
interface QualifiedName extends Node {
|
||||
left: EntityName;
|
||||
right: Identifier;
|
||||
@@ -1047,6 +1046,34 @@ declare namespace ts {
|
||||
postParameterName?: Identifier;
|
||||
isBracketed: boolean;
|
||||
}
|
||||
enum FlowFlags {
|
||||
Unreachable = 1,
|
||||
Start = 2,
|
||||
BranchLabel = 4,
|
||||
LoopLabel = 8,
|
||||
Assignment = 16,
|
||||
TrueCondition = 32,
|
||||
FalseCondition = 64,
|
||||
Referenced = 128,
|
||||
Shared = 256,
|
||||
Label = 12,
|
||||
Condition = 96,
|
||||
}
|
||||
interface FlowNode {
|
||||
flags: FlowFlags;
|
||||
id?: number;
|
||||
}
|
||||
interface FlowLabel extends FlowNode {
|
||||
antecedents: FlowNode[];
|
||||
}
|
||||
interface FlowAssignment extends FlowNode {
|
||||
node: Expression | VariableDeclaration | BindingElement;
|
||||
antecedent: FlowNode;
|
||||
}
|
||||
interface FlowCondition extends FlowNode {
|
||||
expression: Expression;
|
||||
antecedent: FlowNode;
|
||||
}
|
||||
interface AmdDependency {
|
||||
path: string;
|
||||
name: string;
|
||||
@@ -1077,6 +1104,7 @@ declare namespace ts {
|
||||
interface ScriptReferenceHost {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
getSourceFileByPath(path: Path): SourceFile;
|
||||
getCurrentDirectory(): string;
|
||||
}
|
||||
interface ParseConfigHost {
|
||||
@@ -1169,11 +1197,13 @@ declare namespace ts {
|
||||
getIndexTypeOfType(type: Type, kind: IndexKind): Type;
|
||||
getBaseTypes(type: InterfaceType): ObjectType[];
|
||||
getReturnTypeOfSignature(signature: Signature): Type;
|
||||
getNonNullableType(type: Type): Type;
|
||||
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
|
||||
getSymbolAtLocation(node: Node): Symbol;
|
||||
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
|
||||
getShorthandAssignmentValueSymbol(location: Node): Symbol;
|
||||
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol;
|
||||
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol;
|
||||
getTypeAtLocation(node: Node): Type;
|
||||
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
|
||||
symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string;
|
||||
@@ -1233,6 +1263,7 @@ declare namespace ts {
|
||||
WriteTypeArgumentsOfSignature = 32,
|
||||
InElementType = 64,
|
||||
UseFullyQualifiedType = 128,
|
||||
InFirstTypeArgument = 256,
|
||||
}
|
||||
enum SymbolFormatFlags {
|
||||
None = 0,
|
||||
@@ -1356,11 +1387,13 @@ declare namespace ts {
|
||||
ESSymbol = 16777216,
|
||||
ThisType = 33554432,
|
||||
ObjectLiteralPatternWithComputedProperties = 67108864,
|
||||
Never = 134217728,
|
||||
StringLike = 258,
|
||||
NumberLike = 132,
|
||||
ObjectType = 80896,
|
||||
UnionOrIntersection = 49152,
|
||||
StructuredType = 130048,
|
||||
Narrowable = 97793,
|
||||
}
|
||||
type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
|
||||
interface Type {
|
||||
@@ -1525,13 +1558,13 @@ declare namespace ts {
|
||||
lib?: string[];
|
||||
types?: string[];
|
||||
list?: string[];
|
||||
[option: string]: CompilerOptionsValue;
|
||||
[option: string]: CompilerOptionsValue | undefined;
|
||||
}
|
||||
interface TypingOptions {
|
||||
enableAutoDiscovery?: boolean;
|
||||
include?: string[];
|
||||
exclude?: string[];
|
||||
[option: string]: string[] | boolean;
|
||||
[option: string]: string[] | boolean | undefined;
|
||||
}
|
||||
interface DiscoverTypingsInfo {
|
||||
fileNames: string[];
|
||||
@@ -1585,6 +1618,7 @@ declare namespace ts {
|
||||
options: CompilerOptions;
|
||||
typingOptions?: TypingOptions;
|
||||
fileNames: string[];
|
||||
raw?: any;
|
||||
errors: Diagnostic[];
|
||||
}
|
||||
interface ModuleResolutionHost {
|
||||
@@ -1592,6 +1626,7 @@ declare namespace ts {
|
||||
readFile(fileName: string): string;
|
||||
trace?(s: string): void;
|
||||
directoryExists?(directoryName: string): boolean;
|
||||
realpath?(path: string): string;
|
||||
}
|
||||
interface ResolvedModule {
|
||||
resolvedFileName: string;
|
||||
@@ -1611,6 +1646,7 @@ declare namespace ts {
|
||||
}
|
||||
interface CompilerHost extends ModuleResolutionHost {
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
getDefaultLibLocation?(): string;
|
||||
@@ -1637,6 +1673,11 @@ declare namespace ts {
|
||||
declare namespace ts {
|
||||
type FileWatcherCallback = (fileName: string, removed?: boolean) => void;
|
||||
type DirectoryWatcherCallback = (directoryName: string) => void;
|
||||
interface WatchedFile {
|
||||
fileName: string;
|
||||
callback: FileWatcherCallback;
|
||||
mtime?: Date;
|
||||
}
|
||||
interface System {
|
||||
args: string[];
|
||||
newLine: string;
|
||||
@@ -1657,6 +1698,7 @@ declare namespace ts {
|
||||
createHash?(data: string): string;
|
||||
getMemoryUsage?(): number;
|
||||
exit(exitCode?: number): void;
|
||||
realpath?(path: string): string;
|
||||
}
|
||||
interface FileWatcher {
|
||||
close(): void;
|
||||
@@ -1843,6 +1885,7 @@ declare namespace ts {
|
||||
getStringIndexType(): Type;
|
||||
getNumberIndexType(): Type;
|
||||
getBaseTypes(): ObjectType[];
|
||||
getNonNullableType(): Type;
|
||||
}
|
||||
interface Signature {
|
||||
getDeclaration(): SignatureDeclaration;
|
||||
@@ -1898,7 +1941,7 @@ declare namespace ts {
|
||||
getScriptFileNames(): string[];
|
||||
getScriptKind?(fileName: string): ScriptKind;
|
||||
getScriptVersion(fileName: string): string;
|
||||
getScriptSnapshot(fileName: string): IScriptSnapshot;
|
||||
getScriptSnapshot(fileName: string): IScriptSnapshot | undefined;
|
||||
getLocalizedDiagnosticMessages?(): any;
|
||||
getCancellationToken?(): HostCancellationToken;
|
||||
getCurrentDirectory(): string;
|
||||
@@ -1951,6 +1994,7 @@ declare namespace ts {
|
||||
getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[];
|
||||
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[];
|
||||
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
|
||||
isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean;
|
||||
getEmitOutput(fileName: string): EmitOutput;
|
||||
getProgram(): Program;
|
||||
dispose(): void;
|
||||
@@ -2266,6 +2310,7 @@ declare namespace ts {
|
||||
* in the registry and a new one was created.
|
||||
*/
|
||||
acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
|
||||
acquireDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile
|
||||
@@ -2279,6 +2324,8 @@ declare namespace ts {
|
||||
* @param version Current version of the file.
|
||||
*/
|
||||
updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
|
||||
updateDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
|
||||
getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey;
|
||||
/**
|
||||
* Informs the DocumentRegistry that a file is not needed any longer.
|
||||
*
|
||||
@@ -2289,8 +2336,12 @@ declare namespace ts {
|
||||
* @param compilationSettings The compilation settings used to acquire the file
|
||||
*/
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
|
||||
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void;
|
||||
reportStats(): string;
|
||||
}
|
||||
type DocumentRegistryBucketKey = string & {
|
||||
__bucketKey: any;
|
||||
};
|
||||
namespace ScriptElementKind {
|
||||
const unknown: string;
|
||||
const warning: string;
|
||||
|
||||
+6353
-5102
File diff suppressed because it is too large.
Load diff
Vendored
+216
-165
@@ -160,173 +160,174 @@ declare namespace ts {
|
||||
IsKeyword = 124,
|
||||
ModuleKeyword = 125,
|
||||
NamespaceKeyword = 126,
|
||||
ReadonlyKeyword = 127,
|
||||
RequireKeyword = 128,
|
||||
NumberKeyword = 129,
|
||||
SetKeyword = 130,
|
||||
StringKeyword = 131,
|
||||
SymbolKeyword = 132,
|
||||
TypeKeyword = 133,
|
||||
UndefinedKeyword = 134,
|
||||
FromKeyword = 135,
|
||||
GlobalKeyword = 136,
|
||||
OfKeyword = 137,
|
||||
QualifiedName = 138,
|
||||
ComputedPropertyName = 139,
|
||||
TypeParameter = 140,
|
||||
Parameter = 141,
|
||||
Decorator = 142,
|
||||
PropertySignature = 143,
|
||||
PropertyDeclaration = 144,
|
||||
MethodSignature = 145,
|
||||
MethodDeclaration = 146,
|
||||
Constructor = 147,
|
||||
GetAccessor = 148,
|
||||
SetAccessor = 149,
|
||||
CallSignature = 150,
|
||||
ConstructSignature = 151,
|
||||
IndexSignature = 152,
|
||||
TypePredicate = 153,
|
||||
TypeReference = 154,
|
||||
FunctionType = 155,
|
||||
ConstructorType = 156,
|
||||
TypeQuery = 157,
|
||||
TypeLiteral = 158,
|
||||
ArrayType = 159,
|
||||
TupleType = 160,
|
||||
UnionType = 161,
|
||||
IntersectionType = 162,
|
||||
ParenthesizedType = 163,
|
||||
ThisType = 164,
|
||||
StringLiteralType = 165,
|
||||
ObjectBindingPattern = 166,
|
||||
ArrayBindingPattern = 167,
|
||||
BindingElement = 168,
|
||||
ArrayLiteralExpression = 169,
|
||||
ObjectLiteralExpression = 170,
|
||||
PropertyAccessExpression = 171,
|
||||
ElementAccessExpression = 172,
|
||||
CallExpression = 173,
|
||||
NewExpression = 174,
|
||||
TaggedTemplateExpression = 175,
|
||||
TypeAssertionExpression = 176,
|
||||
ParenthesizedExpression = 177,
|
||||
FunctionExpression = 178,
|
||||
ArrowFunction = 179,
|
||||
DeleteExpression = 180,
|
||||
TypeOfExpression = 181,
|
||||
VoidExpression = 182,
|
||||
AwaitExpression = 183,
|
||||
PrefixUnaryExpression = 184,
|
||||
PostfixUnaryExpression = 185,
|
||||
BinaryExpression = 186,
|
||||
ConditionalExpression = 187,
|
||||
TemplateExpression = 188,
|
||||
YieldExpression = 189,
|
||||
SpreadElementExpression = 190,
|
||||
ClassExpression = 191,
|
||||
OmittedExpression = 192,
|
||||
ExpressionWithTypeArguments = 193,
|
||||
AsExpression = 194,
|
||||
NonNullExpression = 195,
|
||||
TemplateSpan = 196,
|
||||
SemicolonClassElement = 197,
|
||||
Block = 198,
|
||||
VariableStatement = 199,
|
||||
EmptyStatement = 200,
|
||||
ExpressionStatement = 201,
|
||||
IfStatement = 202,
|
||||
DoStatement = 203,
|
||||
WhileStatement = 204,
|
||||
ForStatement = 205,
|
||||
ForInStatement = 206,
|
||||
ForOfStatement = 207,
|
||||
ContinueStatement = 208,
|
||||
BreakStatement = 209,
|
||||
ReturnStatement = 210,
|
||||
WithStatement = 211,
|
||||
SwitchStatement = 212,
|
||||
LabeledStatement = 213,
|
||||
ThrowStatement = 214,
|
||||
TryStatement = 215,
|
||||
DebuggerStatement = 216,
|
||||
VariableDeclaration = 217,
|
||||
VariableDeclarationList = 218,
|
||||
FunctionDeclaration = 219,
|
||||
ClassDeclaration = 220,
|
||||
InterfaceDeclaration = 221,
|
||||
TypeAliasDeclaration = 222,
|
||||
EnumDeclaration = 223,
|
||||
ModuleDeclaration = 224,
|
||||
ModuleBlock = 225,
|
||||
CaseBlock = 226,
|
||||
GlobalModuleExportDeclaration = 227,
|
||||
ImportEqualsDeclaration = 228,
|
||||
ImportDeclaration = 229,
|
||||
ImportClause = 230,
|
||||
NamespaceImport = 231,
|
||||
NamedImports = 232,
|
||||
ImportSpecifier = 233,
|
||||
ExportAssignment = 234,
|
||||
ExportDeclaration = 235,
|
||||
NamedExports = 236,
|
||||
ExportSpecifier = 237,
|
||||
MissingDeclaration = 238,
|
||||
ExternalModuleReference = 239,
|
||||
JsxElement = 240,
|
||||
JsxSelfClosingElement = 241,
|
||||
JsxOpeningElement = 242,
|
||||
JsxText = 243,
|
||||
JsxClosingElement = 244,
|
||||
JsxAttribute = 245,
|
||||
JsxSpreadAttribute = 246,
|
||||
JsxExpression = 247,
|
||||
CaseClause = 248,
|
||||
DefaultClause = 249,
|
||||
HeritageClause = 250,
|
||||
CatchClause = 251,
|
||||
PropertyAssignment = 252,
|
||||
ShorthandPropertyAssignment = 253,
|
||||
EnumMember = 254,
|
||||
SourceFile = 255,
|
||||
JSDocTypeExpression = 256,
|
||||
JSDocAllType = 257,
|
||||
JSDocUnknownType = 258,
|
||||
JSDocArrayType = 259,
|
||||
JSDocUnionType = 260,
|
||||
JSDocTupleType = 261,
|
||||
JSDocNullableType = 262,
|
||||
JSDocNonNullableType = 263,
|
||||
JSDocRecordType = 264,
|
||||
JSDocRecordMember = 265,
|
||||
JSDocTypeReference = 266,
|
||||
JSDocOptionalType = 267,
|
||||
JSDocFunctionType = 268,
|
||||
JSDocVariadicType = 269,
|
||||
JSDocConstructorType = 270,
|
||||
JSDocThisType = 271,
|
||||
JSDocComment = 272,
|
||||
JSDocTag = 273,
|
||||
JSDocParameterTag = 274,
|
||||
JSDocReturnTag = 275,
|
||||
JSDocTypeTag = 276,
|
||||
JSDocTemplateTag = 277,
|
||||
SyntaxList = 278,
|
||||
Count = 279,
|
||||
NeverKeyword = 127,
|
||||
ReadonlyKeyword = 128,
|
||||
RequireKeyword = 129,
|
||||
NumberKeyword = 130,
|
||||
SetKeyword = 131,
|
||||
StringKeyword = 132,
|
||||
SymbolKeyword = 133,
|
||||
TypeKeyword = 134,
|
||||
UndefinedKeyword = 135,
|
||||
FromKeyword = 136,
|
||||
GlobalKeyword = 137,
|
||||
OfKeyword = 138,
|
||||
QualifiedName = 139,
|
||||
ComputedPropertyName = 140,
|
||||
TypeParameter = 141,
|
||||
Parameter = 142,
|
||||
Decorator = 143,
|
||||
PropertySignature = 144,
|
||||
PropertyDeclaration = 145,
|
||||
MethodSignature = 146,
|
||||
MethodDeclaration = 147,
|
||||
Constructor = 148,
|
||||
GetAccessor = 149,
|
||||
SetAccessor = 150,
|
||||
CallSignature = 151,
|
||||
ConstructSignature = 152,
|
||||
IndexSignature = 153,
|
||||
TypePredicate = 154,
|
||||
TypeReference = 155,
|
||||
FunctionType = 156,
|
||||
ConstructorType = 157,
|
||||
TypeQuery = 158,
|
||||
TypeLiteral = 159,
|
||||
ArrayType = 160,
|
||||
TupleType = 161,
|
||||
UnionType = 162,
|
||||
IntersectionType = 163,
|
||||
ParenthesizedType = 164,
|
||||
ThisType = 165,
|
||||
StringLiteralType = 166,
|
||||
ObjectBindingPattern = 167,
|
||||
ArrayBindingPattern = 168,
|
||||
BindingElement = 169,
|
||||
ArrayLiteralExpression = 170,
|
||||
ObjectLiteralExpression = 171,
|
||||
PropertyAccessExpression = 172,
|
||||
ElementAccessExpression = 173,
|
||||
CallExpression = 174,
|
||||
NewExpression = 175,
|
||||
TaggedTemplateExpression = 176,
|
||||
TypeAssertionExpression = 177,
|
||||
ParenthesizedExpression = 178,
|
||||
FunctionExpression = 179,
|
||||
ArrowFunction = 180,
|
||||
DeleteExpression = 181,
|
||||
TypeOfExpression = 182,
|
||||
VoidExpression = 183,
|
||||
AwaitExpression = 184,
|
||||
PrefixUnaryExpression = 185,
|
||||
PostfixUnaryExpression = 186,
|
||||
BinaryExpression = 187,
|
||||
ConditionalExpression = 188,
|
||||
TemplateExpression = 189,
|
||||
YieldExpression = 190,
|
||||
SpreadElementExpression = 191,
|
||||
ClassExpression = 192,
|
||||
OmittedExpression = 193,
|
||||
ExpressionWithTypeArguments = 194,
|
||||
AsExpression = 195,
|
||||
NonNullExpression = 196,
|
||||
TemplateSpan = 197,
|
||||
SemicolonClassElement = 198,
|
||||
Block = 199,
|
||||
VariableStatement = 200,
|
||||
EmptyStatement = 201,
|
||||
ExpressionStatement = 202,
|
||||
IfStatement = 203,
|
||||
DoStatement = 204,
|
||||
WhileStatement = 205,
|
||||
ForStatement = 206,
|
||||
ForInStatement = 207,
|
||||
ForOfStatement = 208,
|
||||
ContinueStatement = 209,
|
||||
BreakStatement = 210,
|
||||
ReturnStatement = 211,
|
||||
WithStatement = 212,
|
||||
SwitchStatement = 213,
|
||||
LabeledStatement = 214,
|
||||
ThrowStatement = 215,
|
||||
TryStatement = 216,
|
||||
DebuggerStatement = 217,
|
||||
VariableDeclaration = 218,
|
||||
VariableDeclarationList = 219,
|
||||
FunctionDeclaration = 220,
|
||||
ClassDeclaration = 221,
|
||||
InterfaceDeclaration = 222,
|
||||
TypeAliasDeclaration = 223,
|
||||
EnumDeclaration = 224,
|
||||
ModuleDeclaration = 225,
|
||||
ModuleBlock = 226,
|
||||
CaseBlock = 227,
|
||||
GlobalModuleExportDeclaration = 228,
|
||||
ImportEqualsDeclaration = 229,
|
||||
ImportDeclaration = 230,
|
||||
ImportClause = 231,
|
||||
NamespaceImport = 232,
|
||||
NamedImports = 233,
|
||||
ImportSpecifier = 234,
|
||||
ExportAssignment = 235,
|
||||
ExportDeclaration = 236,
|
||||
NamedExports = 237,
|
||||
ExportSpecifier = 238,
|
||||
MissingDeclaration = 239,
|
||||
ExternalModuleReference = 240,
|
||||
JsxElement = 241,
|
||||
JsxSelfClosingElement = 242,
|
||||
JsxOpeningElement = 243,
|
||||
JsxText = 244,
|
||||
JsxClosingElement = 245,
|
||||
JsxAttribute = 246,
|
||||
JsxSpreadAttribute = 247,
|
||||
JsxExpression = 248,
|
||||
CaseClause = 249,
|
||||
DefaultClause = 250,
|
||||
HeritageClause = 251,
|
||||
CatchClause = 252,
|
||||
PropertyAssignment = 253,
|
||||
ShorthandPropertyAssignment = 254,
|
||||
EnumMember = 255,
|
||||
SourceFile = 256,
|
||||
JSDocTypeExpression = 257,
|
||||
JSDocAllType = 258,
|
||||
JSDocUnknownType = 259,
|
||||
JSDocArrayType = 260,
|
||||
JSDocUnionType = 261,
|
||||
JSDocTupleType = 262,
|
||||
JSDocNullableType = 263,
|
||||
JSDocNonNullableType = 264,
|
||||
JSDocRecordType = 265,
|
||||
JSDocRecordMember = 266,
|
||||
JSDocTypeReference = 267,
|
||||
JSDocOptionalType = 268,
|
||||
JSDocFunctionType = 269,
|
||||
JSDocVariadicType = 270,
|
||||
JSDocConstructorType = 271,
|
||||
JSDocThisType = 272,
|
||||
JSDocComment = 273,
|
||||
JSDocTag = 274,
|
||||
JSDocParameterTag = 275,
|
||||
JSDocReturnTag = 276,
|
||||
JSDocTypeTag = 277,
|
||||
JSDocTemplateTag = 278,
|
||||
SyntaxList = 279,
|
||||
Count = 280,
|
||||
FirstAssignment = 56,
|
||||
LastAssignment = 68,
|
||||
FirstReservedWord = 70,
|
||||
LastReservedWord = 105,
|
||||
FirstKeyword = 70,
|
||||
LastKeyword = 137,
|
||||
LastKeyword = 138,
|
||||
FirstFutureReservedWord = 106,
|
||||
LastFutureReservedWord = 114,
|
||||
FirstTypeNode = 153,
|
||||
LastTypeNode = 165,
|
||||
FirstTypeNode = 154,
|
||||
LastTypeNode = 166,
|
||||
FirstPunctuation = 15,
|
||||
LastPunctuation = 68,
|
||||
FirstToken = 0,
|
||||
LastToken = 137,
|
||||
LastToken = 138,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 7,
|
||||
FirstLiteralToken = 8,
|
||||
@@ -335,7 +336,7 @@ declare namespace ts {
|
||||
LastTemplateToken = 14,
|
||||
FirstBinaryOperator = 25,
|
||||
LastBinaryOperator = 68,
|
||||
FirstNode = 138,
|
||||
FirstNode = 139,
|
||||
}
|
||||
enum NodeFlags {
|
||||
None = 0,
|
||||
@@ -370,8 +371,9 @@ declare namespace ts {
|
||||
ThisNodeOrAnySubNodesHasError = 268435456,
|
||||
HasAggregatedChildData = 536870912,
|
||||
HasJsxSpreadAttribute = 1073741824,
|
||||
Modifier = 959,
|
||||
Modifier = 1023,
|
||||
AccessibilityModifier = 28,
|
||||
ParameterPropertyModifier = 92,
|
||||
BlockScoped = 3072,
|
||||
ReachabilityCheckFlags = 98304,
|
||||
EmitHelperFlags = 3932160,
|
||||
@@ -405,9 +407,6 @@ declare namespace ts {
|
||||
text: string;
|
||||
originalKeywordKind?: SyntaxKind;
|
||||
}
|
||||
interface TransientIdentifier extends Identifier {
|
||||
resolvedSymbol: Symbol;
|
||||
}
|
||||
interface QualifiedName extends Node {
|
||||
left: EntityName;
|
||||
right: Identifier;
|
||||
@@ -1047,6 +1046,34 @@ declare namespace ts {
|
||||
postParameterName?: Identifier;
|
||||
isBracketed: boolean;
|
||||
}
|
||||
enum FlowFlags {
|
||||
Unreachable = 1,
|
||||
Start = 2,
|
||||
BranchLabel = 4,
|
||||
LoopLabel = 8,
|
||||
Assignment = 16,
|
||||
TrueCondition = 32,
|
||||
FalseCondition = 64,
|
||||
Referenced = 128,
|
||||
Shared = 256,
|
||||
Label = 12,
|
||||
Condition = 96,
|
||||
}
|
||||
interface FlowNode {
|
||||
flags: FlowFlags;
|
||||
id?: number;
|
||||
}
|
||||
interface FlowLabel extends FlowNode {
|
||||
antecedents: FlowNode[];
|
||||
}
|
||||
interface FlowAssignment extends FlowNode {
|
||||
node: Expression | VariableDeclaration | BindingElement;
|
||||
antecedent: FlowNode;
|
||||
}
|
||||
interface FlowCondition extends FlowNode {
|
||||
expression: Expression;
|
||||
antecedent: FlowNode;
|
||||
}
|
||||
interface AmdDependency {
|
||||
path: string;
|
||||
name: string;
|
||||
@@ -1077,6 +1104,7 @@ declare namespace ts {
|
||||
interface ScriptReferenceHost {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
getSourceFileByPath(path: Path): SourceFile;
|
||||
getCurrentDirectory(): string;
|
||||
}
|
||||
interface ParseConfigHost {
|
||||
@@ -1169,11 +1197,13 @@ declare namespace ts {
|
||||
getIndexTypeOfType(type: Type, kind: IndexKind): Type;
|
||||
getBaseTypes(type: InterfaceType): ObjectType[];
|
||||
getReturnTypeOfSignature(signature: Signature): Type;
|
||||
getNonNullableType(type: Type): Type;
|
||||
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
|
||||
getSymbolAtLocation(node: Node): Symbol;
|
||||
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
|
||||
getShorthandAssignmentValueSymbol(location: Node): Symbol;
|
||||
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol;
|
||||
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol;
|
||||
getTypeAtLocation(node: Node): Type;
|
||||
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
|
||||
symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string;
|
||||
@@ -1233,6 +1263,7 @@ declare namespace ts {
|
||||
WriteTypeArgumentsOfSignature = 32,
|
||||
InElementType = 64,
|
||||
UseFullyQualifiedType = 128,
|
||||
InFirstTypeArgument = 256,
|
||||
}
|
||||
enum SymbolFormatFlags {
|
||||
None = 0,
|
||||
@@ -1356,11 +1387,13 @@ declare namespace ts {
|
||||
ESSymbol = 16777216,
|
||||
ThisType = 33554432,
|
||||
ObjectLiteralPatternWithComputedProperties = 67108864,
|
||||
Never = 134217728,
|
||||
StringLike = 258,
|
||||
NumberLike = 132,
|
||||
ObjectType = 80896,
|
||||
UnionOrIntersection = 49152,
|
||||
StructuredType = 130048,
|
||||
Narrowable = 97793,
|
||||
}
|
||||
type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
|
||||
interface Type {
|
||||
@@ -1525,13 +1558,13 @@ declare namespace ts {
|
||||
lib?: string[];
|
||||
types?: string[];
|
||||
list?: string[];
|
||||
[option: string]: CompilerOptionsValue;
|
||||
[option: string]: CompilerOptionsValue | undefined;
|
||||
}
|
||||
interface TypingOptions {
|
||||
enableAutoDiscovery?: boolean;
|
||||
include?: string[];
|
||||
exclude?: string[];
|
||||
[option: string]: string[] | boolean;
|
||||
[option: string]: string[] | boolean | undefined;
|
||||
}
|
||||
interface DiscoverTypingsInfo {
|
||||
fileNames: string[];
|
||||
@@ -1585,6 +1618,7 @@ declare namespace ts {
|
||||
options: CompilerOptions;
|
||||
typingOptions?: TypingOptions;
|
||||
fileNames: string[];
|
||||
raw?: any;
|
||||
errors: Diagnostic[];
|
||||
}
|
||||
interface ModuleResolutionHost {
|
||||
@@ -1592,6 +1626,7 @@ declare namespace ts {
|
||||
readFile(fileName: string): string;
|
||||
trace?(s: string): void;
|
||||
directoryExists?(directoryName: string): boolean;
|
||||
realpath?(path: string): string;
|
||||
}
|
||||
interface ResolvedModule {
|
||||
resolvedFileName: string;
|
||||
@@ -1611,6 +1646,7 @@ declare namespace ts {
|
||||
}
|
||||
interface CompilerHost extends ModuleResolutionHost {
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
getDefaultLibLocation?(): string;
|
||||
@@ -1637,6 +1673,11 @@ declare namespace ts {
|
||||
declare namespace ts {
|
||||
type FileWatcherCallback = (fileName: string, removed?: boolean) => void;
|
||||
type DirectoryWatcherCallback = (directoryName: string) => void;
|
||||
interface WatchedFile {
|
||||
fileName: string;
|
||||
callback: FileWatcherCallback;
|
||||
mtime?: Date;
|
||||
}
|
||||
interface System {
|
||||
args: string[];
|
||||
newLine: string;
|
||||
@@ -1657,6 +1698,7 @@ declare namespace ts {
|
||||
createHash?(data: string): string;
|
||||
getMemoryUsage?(): number;
|
||||
exit(exitCode?: number): void;
|
||||
realpath?(path: string): string;
|
||||
}
|
||||
interface FileWatcher {
|
||||
close(): void;
|
||||
@@ -1843,6 +1885,7 @@ declare namespace ts {
|
||||
getStringIndexType(): Type;
|
||||
getNumberIndexType(): Type;
|
||||
getBaseTypes(): ObjectType[];
|
||||
getNonNullableType(): Type;
|
||||
}
|
||||
interface Signature {
|
||||
getDeclaration(): SignatureDeclaration;
|
||||
@@ -1898,7 +1941,7 @@ declare namespace ts {
|
||||
getScriptFileNames(): string[];
|
||||
getScriptKind?(fileName: string): ScriptKind;
|
||||
getScriptVersion(fileName: string): string;
|
||||
getScriptSnapshot(fileName: string): IScriptSnapshot;
|
||||
getScriptSnapshot(fileName: string): IScriptSnapshot | undefined;
|
||||
getLocalizedDiagnosticMessages?(): any;
|
||||
getCancellationToken?(): HostCancellationToken;
|
||||
getCurrentDirectory(): string;
|
||||
@@ -1951,6 +1994,7 @@ declare namespace ts {
|
||||
getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[];
|
||||
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[];
|
||||
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
|
||||
isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean;
|
||||
getEmitOutput(fileName: string): EmitOutput;
|
||||
getProgram(): Program;
|
||||
dispose(): void;
|
||||
@@ -2266,6 +2310,7 @@ declare namespace ts {
|
||||
* in the registry and a new one was created.
|
||||
*/
|
||||
acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
|
||||
acquireDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile
|
||||
@@ -2279,6 +2324,8 @@ declare namespace ts {
|
||||
* @param version Current version of the file.
|
||||
*/
|
||||
updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
|
||||
updateDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
|
||||
getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey;
|
||||
/**
|
||||
* Informs the DocumentRegistry that a file is not needed any longer.
|
||||
*
|
||||
@@ -2289,8 +2336,12 @@ declare namespace ts {
|
||||
* @param compilationSettings The compilation settings used to acquire the file
|
||||
*/
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
|
||||
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void;
|
||||
reportStats(): string;
|
||||
}
|
||||
type DocumentRegistryBucketKey = string & {
|
||||
__bucketKey: any;
|
||||
};
|
||||
namespace ScriptElementKind {
|
||||
const unknown: string;
|
||||
const warning: string;
|
||||
|
||||
+6353
-5102
File diff suppressed because it is too large.
Load diff
@@ -67,7 +67,7 @@ function getNightlyVersionString(versionString: string): string {
|
||||
const now = new Date();
|
||||
const timeStr = now.toISOString().replace(/:|T|\.|-/g, "").slice(0, 8);
|
||||
|
||||
return `${versionString}-dev.${timeStr}`;
|
||||
return `${versionString}-dev.${timeStr}-1.0`;
|
||||
}
|
||||
|
||||
main();
|
||||
+67
-48
@@ -129,8 +129,8 @@ namespace ts {
|
||||
let Symbol: { new (flags: SymbolFlags, name: string): Symbol };
|
||||
let classifiableNames: Map<string>;
|
||||
|
||||
const unreachableFlow: FlowNode = { kind: FlowKind.Unreachable };
|
||||
const reportedUnreachableFlow: FlowNode = { kind: FlowKind.Unreachable };
|
||||
const unreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
|
||||
const reportedUnreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
|
||||
|
||||
function bindSourceFile(f: SourceFile, opts: CompilerOptions) {
|
||||
file = f;
|
||||
@@ -138,6 +138,7 @@ namespace ts {
|
||||
languageVersion = getEmitScriptTarget(options);
|
||||
inStrictMode = !!file.externalModuleIndicator;
|
||||
classifiableNames = {};
|
||||
symbolCount = 0;
|
||||
|
||||
Symbol = objectAllocator.getSymbolConstructor();
|
||||
|
||||
@@ -479,7 +480,7 @@ namespace ts {
|
||||
savedActiveLabels = activeLabels;
|
||||
|
||||
hasExplicitReturn = false;
|
||||
currentFlow = { kind: FlowKind.Start };
|
||||
currentFlow = { flags: FlowFlags.Start };
|
||||
currentBreakTarget = undefined;
|
||||
currentContinueTarget = undefined;
|
||||
activeLabels = undefined;
|
||||
@@ -487,7 +488,7 @@ namespace ts {
|
||||
|
||||
bindReachableStatement(node);
|
||||
|
||||
if (currentFlow.kind !== FlowKind.Unreachable && isFunctionLikeKind(kind) && nodeIsPresent((<FunctionLikeDeclaration>node).body)) {
|
||||
if (!(currentFlow.flags & FlowFlags.Unreachable) && isFunctionLikeKind(kind) && nodeIsPresent((<FunctionLikeDeclaration>node).body)) {
|
||||
flags |= NodeFlags.HasImplicitReturn;
|
||||
if (hasExplicitReturn) {
|
||||
flags |= NodeFlags.HasExplicitReturn;
|
||||
@@ -584,6 +585,9 @@ namespace ts {
|
||||
case SyntaxKind.BinaryExpression:
|
||||
bindBinaryExpressionFlow(<BinaryExpression>node);
|
||||
break;
|
||||
case SyntaxKind.DeleteExpression:
|
||||
bindDeleteExpressionFlow(<DeleteExpression>node);
|
||||
break;
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
bindConditionalExpressionFlow(<ConditionalExpression>node);
|
||||
break;
|
||||
@@ -643,50 +647,58 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function createFlowLabel(): FlowLabel {
|
||||
function createBranchLabel(): FlowLabel {
|
||||
return {
|
||||
kind: FlowKind.Label,
|
||||
flags: FlowFlags.BranchLabel,
|
||||
antecedents: undefined
|
||||
};
|
||||
}
|
||||
|
||||
function createFlowLoopLabel(): FlowLabel {
|
||||
function createLoopLabel(): FlowLabel {
|
||||
return {
|
||||
kind: FlowKind.LoopLabel,
|
||||
flags: FlowFlags.LoopLabel,
|
||||
antecedents: undefined
|
||||
};
|
||||
}
|
||||
|
||||
function setFlowNodeReferenced(flow: FlowNode) {
|
||||
// On first reference we set the Referenced flag, thereafter we set the Shared flag
|
||||
flow.flags |= flow.flags & FlowFlags.Referenced ? FlowFlags.Shared : FlowFlags.Referenced;
|
||||
}
|
||||
|
||||
function addAntecedent(label: FlowLabel, antecedent: FlowNode): void {
|
||||
if (antecedent.kind !== FlowKind.Unreachable && !contains(label.antecedents, antecedent)) {
|
||||
if (!(antecedent.flags & FlowFlags.Unreachable) && !contains(label.antecedents, antecedent)) {
|
||||
(label.antecedents || (label.antecedents = [])).push(antecedent);
|
||||
setFlowNodeReferenced(antecedent);
|
||||
}
|
||||
}
|
||||
|
||||
function createFlowCondition(antecedent: FlowNode, expression: Expression, assumeTrue: boolean): FlowNode {
|
||||
if (antecedent.kind === FlowKind.Unreachable) {
|
||||
function createFlowCondition(flags: FlowFlags, antecedent: FlowNode, expression: Expression): FlowNode {
|
||||
if (antecedent.flags & FlowFlags.Unreachable) {
|
||||
return antecedent;
|
||||
}
|
||||
if (!expression) {
|
||||
return assumeTrue ? antecedent : unreachableFlow;
|
||||
return flags & FlowFlags.TrueCondition ? antecedent : unreachableFlow;
|
||||
}
|
||||
if (expression.kind === SyntaxKind.TrueKeyword && !assumeTrue || expression.kind === SyntaxKind.FalseKeyword && assumeTrue) {
|
||||
if (expression.kind === SyntaxKind.TrueKeyword && flags & FlowFlags.FalseCondition ||
|
||||
expression.kind === SyntaxKind.FalseKeyword && flags & FlowFlags.TrueCondition) {
|
||||
return unreachableFlow;
|
||||
}
|
||||
if (!isNarrowingExpression(expression)) {
|
||||
return antecedent;
|
||||
}
|
||||
setFlowNodeReferenced(antecedent);
|
||||
return <FlowCondition>{
|
||||
kind: FlowKind.Condition,
|
||||
flags,
|
||||
antecedent,
|
||||
expression,
|
||||
assumeTrue
|
||||
};
|
||||
}
|
||||
|
||||
function createFlowAssignment(antecedent: FlowNode, node: Expression | VariableDeclaration | BindingElement): FlowNode {
|
||||
setFlowNodeReferenced(antecedent);
|
||||
return <FlowAssignment>{
|
||||
kind: FlowKind.Assignment,
|
||||
flags: FlowFlags.Assignment,
|
||||
antecedent,
|
||||
node
|
||||
};
|
||||
@@ -751,8 +763,8 @@ namespace ts {
|
||||
currentTrueTarget = saveTrueTarget;
|
||||
currentFalseTarget = saveFalseTarget;
|
||||
if (!node || !isLogicalExpression(node)) {
|
||||
addAntecedent(trueTarget, createFlowCondition(currentFlow, node, /*assumeTrue*/ true));
|
||||
addAntecedent(falseTarget, createFlowCondition(currentFlow, node, /*assumeTrue*/ false));
|
||||
addAntecedent(trueTarget, createFlowCondition(FlowFlags.TrueCondition, currentFlow, node));
|
||||
addAntecedent(falseTarget, createFlowCondition(FlowFlags.FalseCondition, currentFlow, node));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -767,9 +779,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindWhileStatement(node: WhileStatement): void {
|
||||
const preWhileLabel = createFlowLoopLabel();
|
||||
const preBodyLabel = createFlowLabel();
|
||||
const postWhileLabel = createFlowLabel();
|
||||
const preWhileLabel = createLoopLabel();
|
||||
const preBodyLabel = createBranchLabel();
|
||||
const postWhileLabel = createBranchLabel();
|
||||
addAntecedent(preWhileLabel, currentFlow);
|
||||
currentFlow = preWhileLabel;
|
||||
bindCondition(node.expression, preBodyLabel, postWhileLabel);
|
||||
@@ -780,9 +792,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindDoStatement(node: DoStatement): void {
|
||||
const preDoLabel = createFlowLoopLabel();
|
||||
const preConditionLabel = createFlowLabel();
|
||||
const postDoLabel = createFlowLabel();
|
||||
const preDoLabel = createLoopLabel();
|
||||
const preConditionLabel = createBranchLabel();
|
||||
const postDoLabel = createBranchLabel();
|
||||
addAntecedent(preDoLabel, currentFlow);
|
||||
currentFlow = preDoLabel;
|
||||
bindIterativeStatement(node.statement, postDoLabel, preConditionLabel);
|
||||
@@ -793,9 +805,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindForStatement(node: ForStatement): void {
|
||||
const preLoopLabel = createFlowLoopLabel();
|
||||
const preBodyLabel = createFlowLabel();
|
||||
const postLoopLabel = createFlowLabel();
|
||||
const preLoopLabel = createLoopLabel();
|
||||
const preBodyLabel = createBranchLabel();
|
||||
const postLoopLabel = createBranchLabel();
|
||||
bind(node.initializer);
|
||||
addAntecedent(preLoopLabel, currentFlow);
|
||||
currentFlow = preLoopLabel;
|
||||
@@ -808,8 +820,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindForInOrForOfStatement(node: ForInStatement | ForOfStatement): void {
|
||||
const preLoopLabel = createFlowLoopLabel();
|
||||
const postLoopLabel = createFlowLabel();
|
||||
const preLoopLabel = createLoopLabel();
|
||||
const postLoopLabel = createBranchLabel();
|
||||
addAntecedent(preLoopLabel, currentFlow);
|
||||
currentFlow = preLoopLabel;
|
||||
bind(node.expression);
|
||||
@@ -824,9 +836,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindIfStatement(node: IfStatement): void {
|
||||
const thenLabel = createFlowLabel();
|
||||
const elseLabel = createFlowLabel();
|
||||
const postIfLabel = createFlowLabel();
|
||||
const thenLabel = createBranchLabel();
|
||||
const elseLabel = createBranchLabel();
|
||||
const postIfLabel = createBranchLabel();
|
||||
bindCondition(node.expression, thenLabel, elseLabel);
|
||||
currentFlow = finishFlowLabel(thenLabel);
|
||||
bind(node.thenStatement);
|
||||
@@ -879,7 +891,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindTryStatement(node: TryStatement): void {
|
||||
const postFinallyLabel = createFlowLabel();
|
||||
const postFinallyLabel = createBranchLabel();
|
||||
const preTryFlow = currentFlow;
|
||||
// TODO: Every statement in try block is potentially an exit point!
|
||||
bind(node.tryBlock);
|
||||
@@ -897,7 +909,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindSwitchStatement(node: SwitchStatement): void {
|
||||
const postSwitchLabel = createFlowLabel();
|
||||
const postSwitchLabel = createBranchLabel();
|
||||
bind(node.expression);
|
||||
const saveBreakTarget = currentBreakTarget;
|
||||
const savePreSwitchCaseFlow = preSwitchCaseFlow;
|
||||
@@ -919,17 +931,17 @@ namespace ts {
|
||||
for (let i = 0; i < clauses.length; i++) {
|
||||
const clause = clauses[i];
|
||||
if (clause.statements.length) {
|
||||
if (currentFlow.kind === FlowKind.Unreachable) {
|
||||
if (currentFlow.flags & FlowFlags.Unreachable) {
|
||||
currentFlow = preSwitchCaseFlow;
|
||||
}
|
||||
else {
|
||||
const preCaseLabel = createFlowLabel();
|
||||
const preCaseLabel = createBranchLabel();
|
||||
addAntecedent(preCaseLabel, preSwitchCaseFlow);
|
||||
addAntecedent(preCaseLabel, currentFlow);
|
||||
currentFlow = finishFlowLabel(preCaseLabel);
|
||||
}
|
||||
bind(clause);
|
||||
if (currentFlow.kind !== FlowKind.Unreachable && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) {
|
||||
if (!(currentFlow.flags & FlowFlags.Unreachable) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) {
|
||||
errorOnFirstToken(clause, Diagnostics.Fallthrough_case_in_switch);
|
||||
}
|
||||
}
|
||||
@@ -955,8 +967,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindLabeledStatement(node: LabeledStatement): void {
|
||||
const preStatementLabel = createFlowLoopLabel();
|
||||
const postStatementLabel = createFlowLabel();
|
||||
const preStatementLabel = createLoopLabel();
|
||||
const postStatementLabel = createBranchLabel();
|
||||
bind(node.label);
|
||||
addAntecedent(preStatementLabel, currentFlow);
|
||||
const activeLabel = pushActiveLabel(node.label.text, postStatementLabel, preStatementLabel);
|
||||
@@ -1005,7 +1017,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindLogicalExpression(node: BinaryExpression, trueTarget: FlowLabel, falseTarget: FlowLabel) {
|
||||
const preRightLabel = createFlowLabel();
|
||||
const preRightLabel = createBranchLabel();
|
||||
if (node.operatorToken.kind === SyntaxKind.AmpersandAmpersandToken) {
|
||||
bindCondition(node.left, preRightLabel, falseTarget);
|
||||
}
|
||||
@@ -1035,7 +1047,7 @@ namespace ts {
|
||||
const operator = node.operatorToken.kind;
|
||||
if (operator === SyntaxKind.AmpersandAmpersandToken || operator === SyntaxKind.BarBarToken) {
|
||||
if (isTopLevelLogicalExpression(node)) {
|
||||
const postExpressionLabel = createFlowLabel();
|
||||
const postExpressionLabel = createBranchLabel();
|
||||
bindLogicalExpression(node, postExpressionLabel, postExpressionLabel);
|
||||
currentFlow = finishFlowLabel(postExpressionLabel);
|
||||
}
|
||||
@@ -1051,10 +1063,17 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function bindDeleteExpressionFlow(node: DeleteExpression) {
|
||||
forEachChild(node, bind);
|
||||
if (node.expression.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
bindAssignmentTargetFlow(node.expression);
|
||||
}
|
||||
}
|
||||
|
||||
function bindConditionalExpressionFlow(node: ConditionalExpression) {
|
||||
const trueLabel = createFlowLabel();
|
||||
const falseLabel = createFlowLabel();
|
||||
const postExpressionLabel = createFlowLabel();
|
||||
const trueLabel = createBranchLabel();
|
||||
const falseLabel = createBranchLabel();
|
||||
const postExpressionLabel = createBranchLabel();
|
||||
bindCondition(node.condition, trueLabel, falseLabel);
|
||||
currentFlow = finishFlowLabel(trueLabel);
|
||||
bind(node.whenTrue);
|
||||
@@ -1755,8 +1774,8 @@ namespace ts {
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
return declareSymbolAndAddToSymbolTable(<Declaration>node, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
|
||||
case SyntaxKind.GlobalModuleExportDeclaration:
|
||||
return bindGlobalModuleExportDeclaration(<GlobalModuleExportDeclaration>node);
|
||||
case SyntaxKind.NamespaceExportDeclaration:
|
||||
return bindNamespaceExportDeclaration(<NamespaceExportDeclaration>node);
|
||||
case SyntaxKind.ImportClause:
|
||||
return bindImportClause(<ImportClause>node);
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
@@ -1806,7 +1825,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function bindGlobalModuleExportDeclaration(node: GlobalModuleExportDeclaration) {
|
||||
function bindNamespaceExportDeclaration(node: NamespaceExportDeclaration) {
|
||||
if (node.modifiers && node.modifiers.length) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Modifiers_cannot_appear_here));
|
||||
}
|
||||
@@ -2074,7 +2093,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function checkUnreachable(node: Node): boolean {
|
||||
if (currentFlow.kind !== FlowKind.Unreachable) {
|
||||
if (!(currentFlow.flags & FlowFlags.Unreachable)) {
|
||||
return false;
|
||||
}
|
||||
if (currentFlow === unreachableFlow) {
|
||||
|
||||
+768
-411
File diff suppressed because it is too large.
Load diff
@@ -37,6 +37,11 @@ namespace ts {
|
||||
type: "boolean",
|
||||
description: Diagnostics.Print_this_message,
|
||||
},
|
||||
{
|
||||
name: "help",
|
||||
shortName: "?",
|
||||
type: "boolean"
|
||||
},
|
||||
{
|
||||
name: "init",
|
||||
type: "boolean",
|
||||
@@ -139,11 +144,16 @@ namespace ts {
|
||||
name: "skipDefaultLibCheck",
|
||||
type: "boolean",
|
||||
},
|
||||
{
|
||||
name: "skipLibCheck",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Skip_type_checking_of_declaration_files,
|
||||
},
|
||||
{
|
||||
name: "out",
|
||||
type: "string",
|
||||
isFilePath: false, // This is intentionally broken to support compatability with existing tsconfig files
|
||||
// for correct behaviour, please use outFile
|
||||
// for correct behaviour, please use outFile
|
||||
paramType: Diagnostics.FILE,
|
||||
},
|
||||
{
|
||||
@@ -375,6 +385,7 @@ namespace ts {
|
||||
"es2015": "lib.es2015.d.ts",
|
||||
"es7": "lib.es2016.d.ts",
|
||||
"es2016": "lib.es2016.d.ts",
|
||||
"es2017": "lib.es2017.d.ts",
|
||||
// Host only
|
||||
"dom": "lib.dom.d.ts",
|
||||
"webworker": "lib.webworker.d.ts",
|
||||
@@ -389,7 +400,8 @@ namespace ts {
|
||||
"es2015.reflect": "lib.es2015.reflect.d.ts",
|
||||
"es2015.symbol": "lib.es2015.symbol.d.ts",
|
||||
"es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts",
|
||||
"es2016.array.include": "lib.es2016.array.include.d.ts"
|
||||
"es2016.array.include": "lib.es2016.array.include.d.ts",
|
||||
"es2017.object": "lib.es2017.object.d.ts"
|
||||
},
|
||||
},
|
||||
description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon
|
||||
@@ -464,7 +476,7 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]) {
|
||||
const key = (value || "").trim().toLowerCase();
|
||||
const key = trimString((value || "")).toLowerCase();
|
||||
const map = opt.type;
|
||||
if (hasProperty(map, key)) {
|
||||
return map[key];
|
||||
@@ -476,7 +488,7 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export function parseListTypeOption(opt: CommandLineOptionOfListType, value: string, errors: Diagnostic[]): (string | number)[] {
|
||||
const values = (value || "").trim().split(",");
|
||||
const values = trimString((value || "")).split(",");
|
||||
switch (opt.element.type) {
|
||||
case "number":
|
||||
return ts.map(values, parseInt);
|
||||
@@ -601,7 +613,7 @@ namespace ts {
|
||||
* Read tsconfig.json file
|
||||
* @param fileName The path to the config file
|
||||
*/
|
||||
export function readConfigFile(fileName: string, readFile: (path: string) => string): { config?: any; error?: Diagnostic } {
|
||||
export function readConfigFile(fileName: string, readFile: (path: string) => string): { config?: any; error?: Diagnostic } {
|
||||
let text = "";
|
||||
try {
|
||||
text = readFile(fileName);
|
||||
@@ -652,6 +664,9 @@ namespace ts {
|
||||
return output;
|
||||
}
|
||||
|
||||
// Skip over any minified JavaScript files (ending in ".min.js")
|
||||
// Skip over dotted files and folders as well
|
||||
const IgnoreFileNamePattern = /(\.min\.js$)|([\\/]\.[\w.])/;
|
||||
/**
|
||||
* Parse the contents of a config file (tsconfig.json).
|
||||
* @param json The contents of the config file to parse
|
||||
@@ -664,6 +679,7 @@ namespace ts {
|
||||
const compilerOptions: CompilerOptions = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName);
|
||||
const options = extend(existingOptions, compilerOptions);
|
||||
const typingOptions: TypingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName);
|
||||
|
||||
options.configFilePath = configFileName;
|
||||
|
||||
const fileNames = getFileNames(errors);
|
||||
@@ -672,6 +688,7 @@ namespace ts {
|
||||
options,
|
||||
fileNames,
|
||||
typingOptions,
|
||||
raw: json,
|
||||
errors
|
||||
};
|
||||
|
||||
@@ -694,11 +711,11 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
// by default exclude node_modules, and any specificied output directory
|
||||
exclude = ["node_modules"];
|
||||
const outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"];
|
||||
if (outDir) {
|
||||
exclude.push(outDir);
|
||||
}
|
||||
exclude = ["node_modules", "bower_components", "jspm_packages"];
|
||||
}
|
||||
const outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"];
|
||||
if (outDir) {
|
||||
exclude.push(outDir);
|
||||
}
|
||||
exclude = map(exclude, normalizeSlashes);
|
||||
|
||||
@@ -715,8 +732,7 @@ namespace ts {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip over any minified JavaScript files (ending in ".min.js")
|
||||
if (/\.min\.js$/.test(fileName)) {
|
||||
if (IgnoreFileNamePattern.test(fileName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -775,7 +791,7 @@ namespace ts {
|
||||
defaultOptions: CompilerOptions | TypingOptions, diagnosticMessage: DiagnosticMessage, errors: Diagnostic[]) {
|
||||
|
||||
if (!jsonOptions) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
const optionNameMap = arrayToMap(optionDeclarations, opt => opt.name);
|
||||
@@ -829,4 +845,8 @@ namespace ts {
|
||||
function convertJsonOptionOfListType(option: CommandLineOptionOfListType, values: any[], basePath: string, errors: Diagnostic[]): any[] {
|
||||
return filter(map(values, v => convertJsonOption(option.element, v, basePath, errors)), v => !!v);
|
||||
}
|
||||
|
||||
function trimString(s: string) {
|
||||
return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, "");
|
||||
}
|
||||
}
|
||||
@@ -395,6 +395,7 @@ namespace ts {
|
||||
case SyntaxKind.VoidKeyword:
|
||||
case SyntaxKind.UndefinedKeyword:
|
||||
case SyntaxKind.NullKeyword:
|
||||
case SyntaxKind.NeverKeyword:
|
||||
case SyntaxKind.ThisType:
|
||||
case SyntaxKind.StringLiteralType:
|
||||
return writeTextOfNode(currentText, type);
|
||||
@@ -1051,7 +1052,7 @@ namespace ts {
|
||||
function emitParameterProperties(constructorDeclaration: ConstructorDeclaration) {
|
||||
if (constructorDeclaration) {
|
||||
forEach(constructorDeclaration.parameters, param => {
|
||||
if (param.flags & NodeFlags.AccessibilityModifier) {
|
||||
if (param.flags & NodeFlags.ParameterPropertyModifier) {
|
||||
emitPropertyDeclaration(param);
|
||||
}
|
||||
});
|
||||
@@ -1129,7 +1130,7 @@ namespace ts {
|
||||
// what we want, namely the name expression enclosed in brackets.
|
||||
writeTextOfNode(currentText, node.name);
|
||||
// If optional property emit ?
|
||||
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) && hasQuestionToken(node)) {
|
||||
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature || node.kind === SyntaxKind.Parameter) && hasQuestionToken(node)) {
|
||||
write("?");
|
||||
}
|
||||
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) && node.parent.kind === SyntaxKind.TypeLiteral) {
|
||||
|
||||
@@ -315,10 +315,6 @@
|
||||
"category": "Error",
|
||||
"code": 1110
|
||||
},
|
||||
"A class member cannot be declared optional.": {
|
||||
"category": "Error",
|
||||
"code": 1112
|
||||
},
|
||||
"A 'default' clause cannot appear more than once in a 'switch' statement.": {
|
||||
"category": "Error",
|
||||
"code": 1113
|
||||
@@ -447,7 +443,7 @@
|
||||
"category": "Error",
|
||||
"code": 1147
|
||||
},
|
||||
"Cannot compile modules unless the '--module' flag is provided with a valid module type. Consider setting the 'module' compiler option in a 'tsconfig.json' file.": {
|
||||
"Cannot use imports, exports, or module augmentations when '--module' is 'none'.": {
|
||||
"category": "Error",
|
||||
"code": 1148
|
||||
},
|
||||
@@ -1755,6 +1751,10 @@
|
||||
"category": "Error",
|
||||
"code": 2533
|
||||
},
|
||||
"A function returning 'never' cannot have a reachable end point.": {
|
||||
"category": "Error",
|
||||
"code": 2534
|
||||
},
|
||||
"JSX element attributes type '{0}' may not be a union type.": {
|
||||
"category": "Error",
|
||||
"code": 2600
|
||||
@@ -1847,10 +1847,6 @@
|
||||
"category": "Error",
|
||||
"code": 2664
|
||||
},
|
||||
"Module augmentation cannot introduce new names in the top level scope.": {
|
||||
"category": "Error",
|
||||
"code": 2665
|
||||
},
|
||||
"Exports and export assignments are not permitted in module augmentations.": {
|
||||
"category": "Error",
|
||||
"code": 2666
|
||||
@@ -1915,7 +1911,7 @@
|
||||
"category": "Error",
|
||||
"code": 2681
|
||||
},
|
||||
"A setter cannot have a 'this' parameter.": {
|
||||
"'get' and 'set' accessor must have the same 'this' type.": {
|
||||
"category": "Error",
|
||||
"code": 2682
|
||||
},
|
||||
@@ -1931,6 +1927,14 @@
|
||||
"category": "Error",
|
||||
"code": 2685
|
||||
},
|
||||
"Identifier '{0}' must be imported from a module": {
|
||||
"category": "Error",
|
||||
"code": 2686
|
||||
},
|
||||
"All declarations of '{0}' must have identical modifiers.": {
|
||||
"category": "Error",
|
||||
"code": 2687
|
||||
},
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 4000
|
||||
@@ -2304,7 +2308,7 @@
|
||||
"category": "Error",
|
||||
"code": 5062
|
||||
},
|
||||
"Substututions for pattern '{0}' should be an array.": {
|
||||
"Substitutions for pattern '{0}' should be an array.": {
|
||||
"category": "Error",
|
||||
"code": 5063
|
||||
},
|
||||
@@ -2356,6 +2360,10 @@
|
||||
"category": "Message",
|
||||
"code": 6011
|
||||
},
|
||||
"Skip type checking of declaration files.": {
|
||||
"category": "Message",
|
||||
"code": 6012
|
||||
},
|
||||
"Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015'": {
|
||||
"category": "Message",
|
||||
"code": 6015
|
||||
@@ -2752,6 +2760,19 @@
|
||||
"category": "Message",
|
||||
"code": 6128
|
||||
},
|
||||
"The config file '{0}' found doesn't contain any source files.": {
|
||||
"category": "Error",
|
||||
"code": 6129
|
||||
},
|
||||
"Resolving real path for '{0}', result '{1}'": {
|
||||
"category": "Message",
|
||||
"code": 6130
|
||||
},
|
||||
"Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'.": {
|
||||
"category": "Error",
|
||||
"code": 6131
|
||||
},
|
||||
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
"code": 7005
|
||||
|
||||
@@ -1953,7 +1953,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
write("Object.defineProperty(");
|
||||
emit(tempVar);
|
||||
write(", ");
|
||||
emitStart(node.name);
|
||||
emitStart(property.name);
|
||||
emitExpressionForPropertyName(property.name);
|
||||
emitEnd(property.name);
|
||||
write(", {");
|
||||
@@ -4979,7 +4979,7 @@ const _super = (function (geti, seti) {
|
||||
|
||||
function emitParameterPropertyAssignments(node: ConstructorDeclaration) {
|
||||
forEach(node.parameters, param => {
|
||||
if (param.flags & NodeFlags.AccessibilityModifier) {
|
||||
if (param.flags & NodeFlags.ParameterPropertyModifier) {
|
||||
writeLine();
|
||||
emitStart(param);
|
||||
emitStart(param.name);
|
||||
|
||||
+62
-11
@@ -303,8 +303,8 @@ namespace ts {
|
||||
case SyntaxKind.ImportClause:
|
||||
return visitNode(cbNode, (<ImportClause>node).name) ||
|
||||
visitNode(cbNode, (<ImportClause>node).namedBindings);
|
||||
case SyntaxKind.GlobalModuleExportDeclaration:
|
||||
return visitNode(cbNode, (<GlobalModuleExportDeclaration>node).name);
|
||||
case SyntaxKind.NamespaceExportDeclaration:
|
||||
return visitNode(cbNode, (<NamespaceExportDeclaration>node).name);
|
||||
|
||||
case SyntaxKind.NamespaceImport:
|
||||
return visitNode(cbNode, (<NamespaceImport>node).name);
|
||||
@@ -2382,6 +2382,7 @@ namespace ts {
|
||||
case SyntaxKind.BooleanKeyword:
|
||||
case SyntaxKind.SymbolKeyword:
|
||||
case SyntaxKind.UndefinedKeyword:
|
||||
case SyntaxKind.NeverKeyword:
|
||||
// If these are followed by a dot, then parse these out as a dotted type reference instead.
|
||||
const node = tryParse(parseKeywordAndNoDot);
|
||||
return node || parseTypeReference();
|
||||
@@ -2424,6 +2425,7 @@ namespace ts {
|
||||
case SyntaxKind.NullKeyword:
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.TypeOfKeyword:
|
||||
case SyntaxKind.NeverKeyword:
|
||||
case SyntaxKind.OpenBraceToken:
|
||||
case SyntaxKind.OpenBracketToken:
|
||||
case SyntaxKind.LessThanToken:
|
||||
@@ -2699,7 +2701,8 @@ namespace ts {
|
||||
// 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
|
||||
// 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield]
|
||||
// 4) ArrowFunctionExpression[?in,?yield]
|
||||
// 5) [+Yield] YieldExpression[?In]
|
||||
// 5) AsyncArrowFunctionExpression[in,yield,await]
|
||||
// 6) [+Yield] YieldExpression[?In]
|
||||
//
|
||||
// Note: for ease of implementation we treat productions '2' and '3' as the same thing.
|
||||
// (i.e. they're both BinaryExpressions with an assignment operator in it).
|
||||
@@ -2709,11 +2712,18 @@ namespace ts {
|
||||
return parseYieldExpression();
|
||||
}
|
||||
|
||||
// Then, check if we have an arrow function (production '4') that starts with a parenthesized
|
||||
// parameter list. If we do, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
|
||||
// Then, check if we have an arrow function (production '4' and '5') that starts with a parenthesized
|
||||
// parameter list or is an async arrow function.
|
||||
// AsyncArrowFunctionExpression:
|
||||
// 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In]
|
||||
// 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In]
|
||||
// Production (1) of AsyncArrowFunctionExpression is parsed in "tryParseAsyncSimpleArrowFunctionExpression".
|
||||
// And production (2) is parsed in "tryParseParenthesizedArrowFunctionExpression".
|
||||
//
|
||||
// If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
|
||||
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
|
||||
// with AssignmentExpression if we see one.
|
||||
const arrowExpression = tryParseParenthesizedArrowFunctionExpression();
|
||||
const arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
|
||||
if (arrowExpression) {
|
||||
return arrowExpression;
|
||||
}
|
||||
@@ -2805,10 +2815,17 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function parseSimpleArrowFunctionExpression(identifier: Identifier): Expression {
|
||||
function parseSimpleArrowFunctionExpression(identifier: Identifier, asyncModifier?: ModifiersArray): ArrowFunction {
|
||||
Debug.assert(token === SyntaxKind.EqualsGreaterThanToken, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
|
||||
|
||||
const node = <ArrowFunction>createNode(SyntaxKind.ArrowFunction, identifier.pos);
|
||||
let node: ArrowFunction;
|
||||
if (asyncModifier) {
|
||||
node = <ArrowFunction>createNode(SyntaxKind.ArrowFunction, asyncModifier.pos);
|
||||
setModifiers(node, asyncModifier);
|
||||
}
|
||||
else {
|
||||
node = <ArrowFunction>createNode(SyntaxKind.ArrowFunction, identifier.pos);
|
||||
}
|
||||
|
||||
const parameter = <ParameterDeclaration>createNode(SyntaxKind.Parameter, identifier.pos);
|
||||
parameter.name = identifier;
|
||||
@@ -2819,7 +2836,7 @@ namespace ts {
|
||||
node.parameters.end = parameter.end;
|
||||
|
||||
node.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, "=>");
|
||||
node.body = parseArrowFunctionExpressionBody(/*isAsync*/ false);
|
||||
node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
|
||||
|
||||
return finishNode(node);
|
||||
}
|
||||
@@ -2987,6 +3004,40 @@ namespace ts {
|
||||
return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false);
|
||||
}
|
||||
|
||||
function tryParseAsyncSimpleArrowFunctionExpression(): ArrowFunction {
|
||||
// We do a check here so that we won't be doing unnecessarily call to "lookAhead"
|
||||
if (token === SyntaxKind.AsyncKeyword) {
|
||||
const isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker);
|
||||
if (isUnParenthesizedAsyncArrowFunction === Tristate.True) {
|
||||
const asyncModifier = parseModifiersForArrowFunction();
|
||||
const expr = parseBinaryExpressionOrHigher(/*precedence*/ 0);
|
||||
return parseSimpleArrowFunctionExpression(<Identifier>expr, asyncModifier);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function isUnParenthesizedAsyncArrowFunctionWorker(): Tristate {
|
||||
// AsyncArrowFunctionExpression:
|
||||
// 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In]
|
||||
// 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In]
|
||||
if (token === SyntaxKind.AsyncKeyword) {
|
||||
nextToken();
|
||||
// If the "async" is followed by "=>" token then it is not a begining of an async arrow-function
|
||||
// but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher"
|
||||
if (scanner.hasPrecedingLineBreak() || token === SyntaxKind.EqualsGreaterThanToken) {
|
||||
return Tristate.False;
|
||||
}
|
||||
// Check for un-parenthesized AsyncArrowFunction
|
||||
const expr = parseBinaryExpressionOrHigher(/*precedence*/ 0);
|
||||
if (!scanner.hasPrecedingLineBreak() && expr.kind === SyntaxKind.Identifier && token === SyntaxKind.EqualsGreaterThanToken) {
|
||||
return Tristate.True;
|
||||
}
|
||||
}
|
||||
|
||||
return Tristate.False;
|
||||
}
|
||||
|
||||
function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction {
|
||||
const node = <ArrowFunction>createNode(SyntaxKind.ArrowFunction);
|
||||
setModifiers(node, parseModifiersForArrowFunction());
|
||||
@@ -5307,8 +5358,8 @@ namespace ts {
|
||||
return nextToken() === SyntaxKind.SlashToken;
|
||||
}
|
||||
|
||||
function parseGlobalModuleExportDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): GlobalModuleExportDeclaration {
|
||||
const exportDeclaration = <GlobalModuleExportDeclaration>createNode(SyntaxKind.GlobalModuleExportDeclaration, fullStart);
|
||||
function parseGlobalModuleExportDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): NamespaceExportDeclaration {
|
||||
const exportDeclaration = <NamespaceExportDeclaration>createNode(SyntaxKind.NamespaceExportDeclaration, fullStart);
|
||||
exportDeclaration.decorators = decorators;
|
||||
exportDeclaration.modifiers = modifiers;
|
||||
parseExpected(SyntaxKind.AsKeyword);
|
||||
|
||||
+90
-46
@@ -196,8 +196,8 @@ namespace ts {
|
||||
traceEnabled
|
||||
};
|
||||
|
||||
// use typesRoot and fallback to directory that contains tsconfig if typesRoot is not set
|
||||
const rootDir = options.typesRoot || (options.configFilePath ? getDirectoryPath(options.configFilePath) : undefined);
|
||||
// use typesRoot and fallback to directory that contains tsconfig or current directory if typesRoot is not set
|
||||
const rootDir = options.typesRoot || (options.configFilePath ? getDirectoryPath(options.configFilePath) : (host.getCurrentDirectory && host.getCurrentDirectory()));
|
||||
|
||||
if (traceEnabled) {
|
||||
if (containingFile === undefined) {
|
||||
@@ -570,22 +570,29 @@ namespace ts {
|
||||
let resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName,
|
||||
failedLookupLocations, supportedExtensions, state);
|
||||
|
||||
if (resolvedFileName) {
|
||||
return createResolvedModule(resolvedFileName, /*isExternalLibraryImport*/false, failedLookupLocations);
|
||||
let isExternalLibraryImport = false;
|
||||
if (!resolvedFileName) {
|
||||
if (moduleHasNonRelativeName(moduleName)) {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Loading_module_0_from_node_modules_folder, moduleName);
|
||||
}
|
||||
resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state);
|
||||
isExternalLibraryImport = resolvedFileName !== undefined;
|
||||
}
|
||||
else {
|
||||
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
|
||||
resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state);
|
||||
}
|
||||
}
|
||||
|
||||
let isExternalLibraryImport = false;
|
||||
if (moduleHasNonRelativeName(moduleName)) {
|
||||
if (resolvedFileName && host.realpath) {
|
||||
const originalFileName = resolvedFileName;
|
||||
resolvedFileName = normalizePath(host.realpath(resolvedFileName));
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Loading_module_0_from_node_modules_folder, moduleName);
|
||||
trace(host, Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName);
|
||||
}
|
||||
resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state);
|
||||
isExternalLibraryImport = resolvedFileName !== undefined;
|
||||
}
|
||||
else {
|
||||
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
|
||||
resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state);
|
||||
}
|
||||
|
||||
return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations);
|
||||
}
|
||||
|
||||
@@ -868,13 +875,28 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getDefaultTypeDirectiveNames(rootPath: string): string[] {
|
||||
const localTypes = combinePaths(rootPath, "types");
|
||||
const npmTypes = combinePaths(rootPath, "node_modules/@types");
|
||||
let result: string[] = [];
|
||||
if (sys.directoryExists(localTypes)) {
|
||||
result = result.concat(sys.getDirectories(localTypes));
|
||||
}
|
||||
if (sys.directoryExists(npmTypes)) {
|
||||
result = result.concat(sys.getDirectories(npmTypes));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function getDefaultLibLocation(): string {
|
||||
return getDirectoryPath(normalizePath(sys.getExecutingFilePath()));
|
||||
}
|
||||
|
||||
const newLine = getNewLineCharacter(options);
|
||||
const realpath = sys.realpath && ((path: string) => sys.realpath(path));
|
||||
|
||||
return {
|
||||
getDefaultTypeDirectiveNames,
|
||||
getSourceFile,
|
||||
getDefaultLibLocation,
|
||||
getDefaultLibFileName: options => combinePaths(getDefaultLibLocation(), getDefaultLibFileName(options)),
|
||||
@@ -886,7 +908,8 @@ namespace ts {
|
||||
fileExists: fileName => sys.fileExists(fileName),
|
||||
readFile: fileName => sys.readFile(fileName),
|
||||
trace: (s: string) => sys.write(s + newLine),
|
||||
directoryExists: directoryName => sys.directoryExists(directoryName)
|
||||
directoryExists: directoryName => sys.directoryExists(directoryName),
|
||||
realpath
|
||||
};
|
||||
}
|
||||
|
||||
@@ -949,6 +972,23 @@ namespace ts {
|
||||
return resolutions;
|
||||
}
|
||||
|
||||
export function getDefaultTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[] {
|
||||
// Use explicit type list from tsconfig.json
|
||||
if (options.types) {
|
||||
return options.types;
|
||||
}
|
||||
|
||||
// or load all types from the automatic type import fields
|
||||
if (host && host.getDefaultTypeDirectiveNames) {
|
||||
const commonRoot = computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), f => host.getCanonicalFileName(f));
|
||||
if (commonRoot) {
|
||||
return host.getDefaultTypeDirectiveNames(commonRoot);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program {
|
||||
let program: Program;
|
||||
let files: SourceFile[] = [];
|
||||
@@ -996,15 +1036,18 @@ namespace ts {
|
||||
const filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? createFileMap<SourceFile>(fileName => fileName.toLowerCase()) : undefined;
|
||||
|
||||
if (!tryReuseStructureFromOldProgram()) {
|
||||
forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false));
|
||||
|
||||
// load type declarations specified via 'types' argument
|
||||
if (options.types && options.types.length) {
|
||||
const resolutions = resolveTypeReferenceDirectiveNamesWorker(options.types, /*containingFile*/ undefined);
|
||||
for (let i = 0; i < options.types.length; i++) {
|
||||
processTypeReferenceDirective(options.types[i], resolutions[i]);
|
||||
const typeReferences: string[] = getDefaultTypeDirectiveNames(options, rootNames, host);
|
||||
|
||||
if (typeReferences) {
|
||||
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, /*containingFile*/ undefined);
|
||||
for (let i = 0; i < typeReferences.length; i++) {
|
||||
processTypeReferenceDirective(typeReferences[i], resolutions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false));
|
||||
// Do not process the default library if:
|
||||
// - The '--noLib' flag is used.
|
||||
// - A 'no-default-lib' reference comment is encountered in
|
||||
@@ -1030,6 +1073,7 @@ namespace ts {
|
||||
program = {
|
||||
getRootFileNames: () => rootNames,
|
||||
getSourceFile,
|
||||
getSourceFileByPath,
|
||||
getSourceFiles: () => files,
|
||||
getCompilerOptions: () => options,
|
||||
getSyntacticDiagnostics,
|
||||
@@ -1106,7 +1150,11 @@ namespace ts {
|
||||
(oldOptions.allowJs !== options.allowJs) ||
|
||||
(oldOptions.rootDir !== options.rootDir) ||
|
||||
(oldOptions.typesSearchPaths !== options.typesSearchPaths) ||
|
||||
(oldOptions.configFilePath !== options.configFilePath)) {
|
||||
(oldOptions.configFilePath !== options.configFilePath) ||
|
||||
(oldOptions.baseUrl !== options.baseUrl) ||
|
||||
(oldOptions.typesRoot !== options.typesRoot) ||
|
||||
!arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) ||
|
||||
!mapIsEqualTo(oldOptions.paths, options.paths)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1128,7 +1176,10 @@ namespace ts {
|
||||
const modifiedSourceFiles: SourceFile[] = [];
|
||||
|
||||
for (const oldSourceFile of oldProgram.getSourceFiles()) {
|
||||
let newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target);
|
||||
let newSourceFile = host.getSourceFileByPath
|
||||
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.path, options.target)
|
||||
: host.getSourceFile(oldSourceFile.fileName, options.target);
|
||||
|
||||
if (!newSourceFile) {
|
||||
return false;
|
||||
}
|
||||
@@ -1223,6 +1274,7 @@ namespace ts {
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
getNewLine: () => host.getNewLine(),
|
||||
getSourceFile: program.getSourceFile,
|
||||
getSourceFileByPath: program.getSourceFileByPath,
|
||||
getSourceFiles: program.getSourceFiles,
|
||||
writeFile: writeFileCallback || (
|
||||
(fileName, data, writeByteOrderMark, onError, sourceFiles) => host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles)),
|
||||
@@ -1298,7 +1350,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getSourceFile(fileName: string): SourceFile {
|
||||
return filesByName.get(toPath(fileName, currentDirectory, getCanonicalFileName));
|
||||
return getSourceFileByPath(toPath(fileName, currentDirectory, getCanonicalFileName));
|
||||
}
|
||||
|
||||
function getSourceFileByPath(path: Path): SourceFile {
|
||||
return filesByName.get(path);
|
||||
}
|
||||
|
||||
function getDiagnosticsHelper(
|
||||
@@ -1740,10 +1796,6 @@ namespace ts {
|
||||
reportFileNamesDifferOnlyInCasingError(fileName, file.fileName, refFile, refPos, refEnd);
|
||||
}
|
||||
|
||||
if (file) {
|
||||
file.wasReferenced = file.wasReferenced || isReference;
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -1760,7 +1812,6 @@ namespace ts {
|
||||
|
||||
filesByName.set(path, file);
|
||||
if (file) {
|
||||
file.wasReferenced = file.wasReferenced || isReference;
|
||||
file.path = path;
|
||||
|
||||
if (host.useCaseSensitiveFileNames()) {
|
||||
@@ -1886,26 +1937,13 @@ namespace ts {
|
||||
// add file to program only if:
|
||||
// - resolution was successful
|
||||
// - noResolve is falsy
|
||||
// - module name come from the list fo imports
|
||||
// - module name comes from the list of imports
|
||||
const shouldAddFile = resolution &&
|
||||
!options.noResolve &&
|
||||
i < file.imports.length;
|
||||
|
||||
if (shouldAddFile) {
|
||||
const importedFile = findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, /*isReference*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
|
||||
|
||||
if (importedFile && resolution.isExternalLibraryImport) {
|
||||
// Since currently irrespective of allowJs, we only look for supportedTypeScript extension external module files,
|
||||
// this check is ok. Otherwise this would be never true for javascript file
|
||||
if (!isExternalModule(importedFile) && importedFile.statements.length) {
|
||||
const start = getTokenPosOfNode(file.imports[i], file);
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
|
||||
}
|
||||
else if (importedFile.referencedFiles.length) {
|
||||
const firstRef = importedFile.referencedFiles[0];
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition));
|
||||
}
|
||||
}
|
||||
findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, /*isReference*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1999,7 +2037,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Substututions_for_pattern_0_should_be_an_array, key));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Substitutions_for_pattern_0_should_be_an_array, key));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2058,7 +2096,7 @@ namespace ts {
|
||||
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && options.module === ModuleKind.None) {
|
||||
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
|
||||
const span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file));
|
||||
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
|
||||
}
|
||||
|
||||
// Cannot specify module gen target of es6 when below es6
|
||||
@@ -2067,8 +2105,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Cannot specify module gen that isn't amd or system with --out
|
||||
if (outFile && options.module && !(options.module === ModuleKind.AMD || options.module === ModuleKind.System)) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile"));
|
||||
if (outFile) {
|
||||
if (options.module && !(options.module === ModuleKind.AMD || options.module === ModuleKind.System)) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile"));
|
||||
}
|
||||
else if (options.module === undefined && firstExternalModuleSourceFile) {
|
||||
const span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile"));
|
||||
}
|
||||
}
|
||||
|
||||
// there has to be common source directory if user specified --outdir || --sourceRoot
|
||||
|
||||
@@ -91,6 +91,7 @@ namespace ts {
|
||||
"let": SyntaxKind.LetKeyword,
|
||||
"module": SyntaxKind.ModuleKeyword,
|
||||
"namespace": SyntaxKind.NamespaceKeyword,
|
||||
"never": SyntaxKind.NeverKeyword,
|
||||
"new": SyntaxKind.NewKeyword,
|
||||
"null": SyntaxKind.NullKeyword,
|
||||
"number": SyntaxKind.NumberKeyword,
|
||||
|
||||
+21
-1
@@ -24,11 +24,13 @@ namespace ts {
|
||||
createDirectory(path: string): void;
|
||||
getExecutingFilePath(): string;
|
||||
getCurrentDirectory(): string;
|
||||
getDirectories(path: string): string[];
|
||||
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
|
||||
getModifiedTime?(path: string): Date;
|
||||
createHash?(data: string): string;
|
||||
getMemoryUsage?(): number;
|
||||
exit(exitCode?: number): void;
|
||||
realpath?(path: string): string;
|
||||
}
|
||||
|
||||
export interface FileWatcher {
|
||||
@@ -70,9 +72,11 @@ namespace ts {
|
||||
resolvePath(path: string): string;
|
||||
readFile(path: string): string;
|
||||
writeFile(path: string, contents: string): void;
|
||||
getDirectories(path: string): string[];
|
||||
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
|
||||
watchFile?(path: string, callback: FileWatcherCallback): FileWatcher;
|
||||
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
|
||||
realpath(path: string): string;
|
||||
};
|
||||
|
||||
export var sys: System = (function () {
|
||||
@@ -159,6 +163,11 @@ namespace ts {
|
||||
return result.sort();
|
||||
}
|
||||
|
||||
function getDirectories(path: string): string[] {
|
||||
const folder = fso.GetFolder(path);
|
||||
return getNames(folder.subfolders);
|
||||
}
|
||||
|
||||
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
|
||||
const result: string[] = [];
|
||||
exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s)));
|
||||
@@ -212,6 +221,7 @@ namespace ts {
|
||||
getCurrentDirectory() {
|
||||
return new ActiveXObject("WScript.Shell").CurrentDirectory;
|
||||
},
|
||||
getDirectories,
|
||||
readDirectory,
|
||||
exit(exitCode?: number): void {
|
||||
try {
|
||||
@@ -400,6 +410,10 @@ namespace ts {
|
||||
return fileSystemEntryExists(path, FileSystemEntryKind.Directory);
|
||||
}
|
||||
|
||||
function getDirectories(path: string): string[] {
|
||||
return filter<string>(_fs.readdirSync(path), p => fileSystemEntryExists(combinePaths(path, p), FileSystemEntryKind.Directory));
|
||||
}
|
||||
|
||||
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
|
||||
const result: string[] = [];
|
||||
exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s)));
|
||||
@@ -505,6 +519,7 @@ namespace ts {
|
||||
getCurrentDirectory() {
|
||||
return process.cwd();
|
||||
},
|
||||
getDirectories,
|
||||
readDirectory,
|
||||
getModifiedTime(path) {
|
||||
try {
|
||||
@@ -527,12 +542,15 @@ namespace ts {
|
||||
},
|
||||
exit(exitCode?: number): void {
|
||||
process.exit(exitCode);
|
||||
},
|
||||
realpath(path: string): string {
|
||||
return _fs.realpathSync(path);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getChakraSystem(): System {
|
||||
|
||||
const realpath = ChakraHost.realpath && ((path: string) => ChakraHost.realpath(path));
|
||||
return {
|
||||
newLine: ChakraHost.newLine || "\r\n",
|
||||
args: ChakraHost.args,
|
||||
@@ -556,8 +574,10 @@ namespace ts {
|
||||
createDirectory: ChakraHost.createDirectory,
|
||||
getExecutingFilePath: () => ChakraHost.executingFile,
|
||||
getCurrentDirectory: () => ChakraHost.currentDirectory,
|
||||
getDirectories: ChakraHost.getDirectories,
|
||||
readDirectory: ChakraHost.readDirectory,
|
||||
exit: ChakraHost.quit,
|
||||
realpath
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+31
-17
@@ -164,6 +164,7 @@ namespace ts {
|
||||
IsKeyword,
|
||||
ModuleKeyword,
|
||||
NamespaceKeyword,
|
||||
NeverKeyword,
|
||||
ReadonlyKeyword,
|
||||
RequireKeyword,
|
||||
NumberKeyword,
|
||||
@@ -276,7 +277,7 @@ namespace ts {
|
||||
ModuleDeclaration,
|
||||
ModuleBlock,
|
||||
CaseBlock,
|
||||
GlobalModuleExportDeclaration,
|
||||
NamespaceExportDeclaration,
|
||||
ImportEqualsDeclaration,
|
||||
ImportDeclaration,
|
||||
ImportClause,
|
||||
@@ -412,8 +413,10 @@ namespace ts {
|
||||
HasAggregatedChildData = 1 << 29, // If we've computed data from children and cached it in this node
|
||||
HasJsxSpreadAttribute = 1 << 30,
|
||||
|
||||
Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async,
|
||||
Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async | Readonly,
|
||||
AccessibilityModifier = Public | Private | Protected,
|
||||
// Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property.
|
||||
ParameterPropertyModifier = AccessibilityModifier | Readonly,
|
||||
BlockScoped = Let | Const,
|
||||
|
||||
ReachabilityCheckFlags = HasImplicitReturn | HasExplicitReturn,
|
||||
@@ -1344,8 +1347,8 @@ namespace ts {
|
||||
name: Identifier;
|
||||
}
|
||||
|
||||
// @kind(SyntaxKind.GlobalModuleImport)
|
||||
export interface GlobalModuleExportDeclaration extends DeclarationStatement {
|
||||
// @kind(SyntaxKind.NamespaceExportDeclaration)
|
||||
export interface NamespaceExportDeclaration extends DeclarationStatement {
|
||||
name: Identifier;
|
||||
moduleReference: LiteralLikeNode;
|
||||
}
|
||||
@@ -1547,17 +1550,22 @@ namespace ts {
|
||||
isBracketed: boolean;
|
||||
}
|
||||
|
||||
export const enum FlowKind {
|
||||
Unreachable,
|
||||
Start,
|
||||
Label,
|
||||
LoopLabel,
|
||||
Assignment,
|
||||
Condition
|
||||
export const enum FlowFlags {
|
||||
Unreachable = 1 << 0, // Unreachable code
|
||||
Start = 1 << 1, // Start of flow graph
|
||||
BranchLabel = 1 << 2, // Non-looping junction
|
||||
LoopLabel = 1 << 3, // Looping junction
|
||||
Assignment = 1 << 4, // Assignment
|
||||
TrueCondition = 1 << 5, // Condition known to be true
|
||||
FalseCondition = 1 << 6, // Condition known to be false
|
||||
Referenced = 1 << 7, // Referenced as antecedent once
|
||||
Shared = 1 << 8, // Referenced as antecedent more than once
|
||||
Label = BranchLabel | LoopLabel,
|
||||
Condition = TrueCondition | FalseCondition
|
||||
}
|
||||
|
||||
export interface FlowNode {
|
||||
kind: FlowKind; // Node kind
|
||||
flags: FlowFlags;
|
||||
id?: number; // Node id used by flow type cache in checker
|
||||
}
|
||||
|
||||
@@ -1577,7 +1585,6 @@ namespace ts {
|
||||
// node's location in the control flow.
|
||||
export interface FlowCondition extends FlowNode {
|
||||
expression: Expression;
|
||||
assumeTrue: boolean;
|
||||
antecedent: FlowNode;
|
||||
}
|
||||
|
||||
@@ -1624,8 +1631,6 @@ namespace ts {
|
||||
/* @internal */ externalModuleIndicator: Node;
|
||||
// The first node that causes this file to be a CommonJS module
|
||||
/* @internal */ commonJsModuleIndicator: Node;
|
||||
// True if the file was a root file in a compilation or a /// reference targets
|
||||
/* @internal */ wasReferenced?: boolean;
|
||||
|
||||
/* @internal */ identifiers: Map<string>;
|
||||
/* @internal */ nodeCount: number;
|
||||
@@ -1655,6 +1660,7 @@ namespace ts {
|
||||
export interface ScriptReferenceHost {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
getSourceFileByPath(path: Path): SourceFile;
|
||||
getCurrentDirectory(): string;
|
||||
}
|
||||
|
||||
@@ -1797,6 +1803,7 @@ namespace ts {
|
||||
getIndexTypeOfType(type: Type, kind: IndexKind): Type;
|
||||
getBaseTypes(type: InterfaceType): ObjectType[];
|
||||
getReturnTypeOfSignature(signature: Signature): Type;
|
||||
getNonNullableType(type: Type): Type;
|
||||
|
||||
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
|
||||
getSymbolAtLocation(node: Node): Symbol;
|
||||
@@ -2050,7 +2057,7 @@ namespace ts {
|
||||
BlockScopedVariableExcludes = Value,
|
||||
|
||||
ParameterExcludes = Value,
|
||||
PropertyExcludes = Value,
|
||||
PropertyExcludes = None,
|
||||
EnumMemberExcludes = Value,
|
||||
FunctionExcludes = Value & ~(Function | ValueModule),
|
||||
ClassExcludes = (Value | Type) & ~(ValueModule | Interface), // class-interface mergability done in checker.ts
|
||||
@@ -2195,11 +2202,12 @@ namespace ts {
|
||||
ESSymbol = 0x01000000, // Type of symbol primitive introduced in ES6
|
||||
ThisType = 0x02000000, // This type
|
||||
ObjectLiteralPatternWithComputedProperties = 0x04000000, // Object literal type implied by binding pattern has computed properties
|
||||
Never = 0x08000000, // Never type
|
||||
|
||||
/* @internal */
|
||||
Nullable = Undefined | Null,
|
||||
/* @internal */
|
||||
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
|
||||
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null | Never,
|
||||
/* @internal */
|
||||
Primitive = String | Number | Boolean | ESSymbol | Void | Undefined | Null | StringLiteral | Enum,
|
||||
StringLike = String | StringLiteral,
|
||||
@@ -2527,6 +2535,7 @@ namespace ts {
|
||||
allowJs?: boolean;
|
||||
noImplicitUseStrict?: boolean;
|
||||
strictNullChecks?: boolean;
|
||||
skipLibCheck?: boolean;
|
||||
listEmittedFiles?: boolean;
|
||||
lib?: string[];
|
||||
/* @internal */ stripInternal?: boolean;
|
||||
@@ -2624,6 +2633,7 @@ namespace ts {
|
||||
options: CompilerOptions;
|
||||
typingOptions?: TypingOptions;
|
||||
fileNames: string[];
|
||||
raw?: any;
|
||||
errors: Diagnostic[];
|
||||
}
|
||||
|
||||
@@ -2807,6 +2817,8 @@ namespace ts {
|
||||
readFile(fileName: string): string;
|
||||
trace?(s: string): void;
|
||||
directoryExists?(directoryName: string): boolean;
|
||||
realpath?(path: string): string;
|
||||
getCurrentDirectory?(): string;
|
||||
}
|
||||
|
||||
export interface ResolvedModule {
|
||||
@@ -2839,9 +2851,11 @@ namespace ts {
|
||||
|
||||
export interface CompilerHost extends ModuleResolutionHost {
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
getDefaultLibLocation?(): string;
|
||||
getDefaultTypeDirectiveNames?(rootPath: string): string[];
|
||||
writeFile: WriteFileCallback;
|
||||
getCurrentDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
|
||||
@@ -84,6 +84,25 @@ namespace ts {
|
||||
return node.end - node.pos;
|
||||
}
|
||||
|
||||
export function mapIsEqualTo<T>(map1: Map<T>, map2: Map<T>): boolean {
|
||||
if (!map1 || !map2) {
|
||||
return map1 === map2;
|
||||
}
|
||||
return containsAll(map1, map2) && containsAll(map2, map1);
|
||||
}
|
||||
|
||||
function containsAll<T>(map: Map<T>, other: Map<T>): boolean {
|
||||
for (const key in map) {
|
||||
if (!hasProperty(map, key)) {
|
||||
continue;
|
||||
}
|
||||
if (!hasProperty(other, key) || map[key] !== other[key]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export function arrayIsEqualTo<T>(array1: T[], array2: T[], equaler?: (a: T, b: T) => boolean): boolean {
|
||||
if (!array1 || !array2) {
|
||||
return array1 === array2;
|
||||
@@ -614,6 +633,7 @@ namespace ts {
|
||||
case SyntaxKind.BooleanKeyword:
|
||||
case SyntaxKind.SymbolKeyword:
|
||||
case SyntaxKind.UndefinedKeyword:
|
||||
case SyntaxKind.NeverKeyword:
|
||||
return true;
|
||||
case SyntaxKind.VoidKeyword:
|
||||
return node.parent.kind !== SyntaxKind.VoidExpression;
|
||||
@@ -1076,6 +1096,7 @@ namespace ts {
|
||||
|
||||
export function isExpression(node: Node): boolean {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.SuperKeyword:
|
||||
case SyntaxKind.NullKeyword:
|
||||
case SyntaxKind.TrueKeyword:
|
||||
@@ -1260,8 +1281,15 @@ namespace ts {
|
||||
else if (lhs.expression.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
// chained dot, e.g. x.y.z = expr; this var is the 'x.y' part
|
||||
const innerPropertyAccess = <PropertyAccessExpression>lhs.expression;
|
||||
if (innerPropertyAccess.expression.kind === SyntaxKind.Identifier && innerPropertyAccess.name.text === "prototype") {
|
||||
return SpecialPropertyAssignmentKind.PrototypeProperty;
|
||||
if (innerPropertyAccess.expression.kind === SyntaxKind.Identifier) {
|
||||
// module.exports.name = expr
|
||||
const innerPropertyAccessIdentifier = <Identifier>innerPropertyAccess.expression;
|
||||
if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") {
|
||||
return SpecialPropertyAssignmentKind.ExportsProperty;
|
||||
}
|
||||
if (innerPropertyAccess.name.text === "prototype") {
|
||||
return SpecialPropertyAssignmentKind.PrototypeProperty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1589,6 +1617,12 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isLiteralComputedPropertyDeclarationName(node: Node) {
|
||||
return (node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) &&
|
||||
node.parent.kind === SyntaxKind.ComputedPropertyName &&
|
||||
isDeclaration(node.parent.parent);
|
||||
}
|
||||
|
||||
// Return true if the given identifier is classified as an IdentifierName
|
||||
export function isIdentifierName(node: Identifier): boolean {
|
||||
let parent = node.parent;
|
||||
@@ -1634,7 +1668,7 @@ namespace ts {
|
||||
// export default ...
|
||||
export function isAliasSymbolDeclaration(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.ImportEqualsDeclaration ||
|
||||
node.kind === SyntaxKind.GlobalModuleExportDeclaration ||
|
||||
node.kind === SyntaxKind.NamespaceExportDeclaration ||
|
||||
node.kind === SyntaxKind.ImportClause && !!(<ImportClause>node).name ||
|
||||
node.kind === SyntaxKind.NamespaceImport ||
|
||||
node.kind === SyntaxKind.ImportSpecifier ||
|
||||
@@ -1765,7 +1799,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getPropertyNameForPropertyNameNode(name: DeclarationName): string {
|
||||
if (name.kind === SyntaxKind.Identifier || name.kind === SyntaxKind.StringLiteral || name.kind === SyntaxKind.NumericLiteral) {
|
||||
if (name.kind === SyntaxKind.Identifier || name.kind === SyntaxKind.StringLiteral || name.kind === SyntaxKind.NumericLiteral || name.kind === SyntaxKind.Parameter) {
|
||||
return (<Identifier | LiteralExpression>name).text;
|
||||
}
|
||||
if (name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
@@ -1774,6 +1808,9 @@ namespace ts {
|
||||
const rightHandSideName = (<PropertyAccessExpression>nameExpression).name.text;
|
||||
return getPropertyNameForKnownSymbolName(rightHandSideName);
|
||||
}
|
||||
else if (nameExpression.kind === SyntaxKind.StringLiteral || nameExpression.kind === SyntaxKind.NumericLiteral) {
|
||||
return (<LiteralExpression>nameExpression).text;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
@@ -2294,7 +2331,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getSetAccessorTypeAnnotationNode(accessor: AccessorDeclaration): TypeNode {
|
||||
return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type;
|
||||
if (accessor && accessor.parameters.length > 0) {
|
||||
const hasThis = accessor.parameters.length === 2 &&
|
||||
accessor.parameters[0].name.kind === SyntaxKind.Identifier &&
|
||||
(accessor.parameters[0].name as Identifier).originalKeywordKind === SyntaxKind.ThisKeyword;
|
||||
return accessor.parameters[hasThis ? 1 : 0].type;
|
||||
}
|
||||
}
|
||||
|
||||
export function getAllAccessorDeclarations(declarations: NodeArray<Declaration>, accessor: AccessorDeclaration) {
|
||||
@@ -3031,7 +3073,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean {
|
||||
return node.flags & NodeFlags.AccessibilityModifier && node.parent.kind === SyntaxKind.Constructor && isClassLike(node.parent.parent);
|
||||
return node.flags & NodeFlags.ParameterPropertyModifier && node.parent.kind === SyntaxKind.Constructor && isClassLike(node.parent.parent);
|
||||
}
|
||||
|
||||
export function startsWith(str: string, prefix: string): boolean {
|
||||
|
||||
@@ -89,16 +89,16 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
otherFiles = [];
|
||||
|
||||
if (testCaseContent.settings["noImplicitReferences"] || /require\(/.test(lastUnit.content) || /reference\spath/.test(lastUnit.content)) {
|
||||
toBeCompiled.push({ unitName: this.makeUnitName(lastUnit.name, rootDir), content: lastUnit.content });
|
||||
toBeCompiled.push({ unitName: this.makeUnitName(lastUnit.name, rootDir), content: lastUnit.content, fileOptions: lastUnit.fileOptions });
|
||||
units.forEach(unit => {
|
||||
if (unit.name !== lastUnit.name) {
|
||||
otherFiles.push({ unitName: this.makeUnitName(unit.name, rootDir), content: unit.content });
|
||||
otherFiles.push({ unitName: this.makeUnitName(unit.name, rootDir), content: unit.content, fileOptions: unit.fileOptions });
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
toBeCompiled = units.map(unit => {
|
||||
return { unitName: this.makeUnitName(unit.name, rootDir), content: unit.content };
|
||||
return { unitName: this.makeUnitName(unit.name, rootDir), content: unit.content, fileOptions: unit.fileOptions };
|
||||
});
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
const output = Harness.Compiler.compileFiles(
|
||||
toBeCompiled, otherFiles, harnessSettings, /*options*/ tsConfigOptions, /*currentDirectory*/ undefined);
|
||||
toBeCompiled, otherFiles, harnessSettings, /*options*/ tsConfigOptions, /*currentDirectory*/ harnessSettings["currentDirectory"]);
|
||||
|
||||
options = output.options;
|
||||
result = output.result;
|
||||
|
||||
+40
-22
@@ -1968,12 +1968,12 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyGetScriptLexicalStructureListCount(expected: number) {
|
||||
public verifyNavigationBarCount(expected: number) {
|
||||
const items = this.languageService.getNavigationBarItems(this.activeFile.fileName);
|
||||
const actual = this.getNavigationBarItemsCount(items);
|
||||
|
||||
if (expected !== actual) {
|
||||
this.raiseError(`verifyGetScriptLexicalStructureListCount failed - found: ${actual} navigation items, expected: ${expected}.`);
|
||||
this.raiseError(`verifyNavigationBarCount failed - found: ${actual} navigation items, expected: ${expected}.`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1989,36 +1989,50 @@ namespace FourSlash {
|
||||
return result;
|
||||
}
|
||||
|
||||
public verifyGetScriptLexicalStructureListContains(name: string, kind: string) {
|
||||
const items = this.languageService.getNavigationBarItems(this.activeFile.fileName);
|
||||
public verifyNavigationBarContains(name: string, kind: string, fileName?: string, parentName?: string, isAdditionalSpan?: boolean, markerPosition?: number) {
|
||||
fileName = fileName || this.activeFile.fileName;
|
||||
const items = this.languageService.getNavigationBarItems(fileName);
|
||||
|
||||
if (!items || items.length === 0) {
|
||||
this.raiseError("verifyGetScriptLexicalStructureListContains failed - found 0 navigation items, expected at least one.");
|
||||
this.raiseError("verifyNavigationBarContains failed - found 0 navigation items, expected at least one.");
|
||||
}
|
||||
|
||||
if (this.navigationBarItemsContains(items, name, kind)) {
|
||||
if (this.navigationBarItemsContains(items, name, kind, parentName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const missingItem = { name: name, kind: kind };
|
||||
this.raiseError(`verifyGetScriptLexicalStructureListContains failed - could not find the item: ${JSON.stringify(missingItem, undefined, 2)} in the returned list: (${JSON.stringify(items, undefined, 2)})`);
|
||||
const missingItem = { name, kind, parentName };
|
||||
this.raiseError(`verifyNavigationBarContains failed - could not find the item: ${JSON.stringify(missingItem, undefined, 2)} in the returned list: (${JSON.stringify(items, undefined, 2)})`);
|
||||
}
|
||||
|
||||
private navigationBarItemsContains(items: ts.NavigationBarItem[], name: string, kind: string) {
|
||||
if (items) {
|
||||
private navigationBarItemsContains(items: ts.NavigationBarItem[], name: string, kind: string, parentName?: string) {
|
||||
function recur(items: ts.NavigationBarItem[], curParentName: string) {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
if (item && item.text === name && item.kind === kind) {
|
||||
if (item && item.text === name && item.kind === kind && (!parentName || curParentName === parentName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.navigationBarItemsContains(item.childItems, name, kind)) {
|
||||
if (recur(item.childItems, item.text)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return recur(items, "");
|
||||
}
|
||||
|
||||
return false;
|
||||
public verifyNavigationBarChildItem(parent: string, name: string, kind: string) {
|
||||
const items = this.languageService.getNavigationBarItems(this.activeFile.fileName);
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
if (item.text === parent) {
|
||||
if (this.navigationBarItemsContains(item.childItems, name, kind))
|
||||
return;
|
||||
const missingItem = { name, kind };
|
||||
this.raiseError(`verifyNavigationBarChildItem failed - could not find the item: ${JSON.stringify(missingItem)} in the children list: (${JSON.stringify(item.childItems, undefined, 2)})`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public printNavigationItems(searchValue: string) {
|
||||
@@ -2033,11 +2047,11 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public printScriptLexicalStructureItems() {
|
||||
public printNavigationBar() {
|
||||
const items = this.languageService.getNavigationBarItems(this.activeFile.fileName);
|
||||
const length = items && items.length;
|
||||
|
||||
Harness.IO.log(`NavigationItems list (${length} items)`);
|
||||
Harness.IO.log(`Navigation bar (${length} items)`);
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
const item = items[i];
|
||||
@@ -3029,19 +3043,23 @@ namespace FourSlashInterface {
|
||||
this.DocCommentTemplate(/*expectedText*/ undefined, /*expectedOffset*/ undefined, /*empty*/ true);
|
||||
}
|
||||
|
||||
public getScriptLexicalStructureListCount(count: number) {
|
||||
this.state.verifyGetScriptLexicalStructureListCount(count);
|
||||
public navigationBarCount(count: number) {
|
||||
this.state.verifyNavigationBarCount(count);
|
||||
}
|
||||
|
||||
// TODO: figure out what to do with the unused arguments.
|
||||
public getScriptLexicalStructureListContains(
|
||||
public navigationBarContains(
|
||||
name: string,
|
||||
kind: string,
|
||||
fileName?: string,
|
||||
parentName?: string,
|
||||
isAdditionalSpan?: boolean,
|
||||
markerPosition?: number) {
|
||||
this.state.verifyGetScriptLexicalStructureListContains(name, kind);
|
||||
this.state.verifyNavigationBarContains(name, kind, fileName, parentName, isAdditionalSpan, markerPosition);
|
||||
}
|
||||
|
||||
public navigationBarChildItem(parent: string, name: string, kind: string) {
|
||||
this.state.verifyNavigationBarChildItem(parent, name, kind);
|
||||
}
|
||||
|
||||
public navigationItemsListCount(count: number, searchValue: string, matchKind?: string) {
|
||||
@@ -3234,8 +3252,8 @@ namespace FourSlashInterface {
|
||||
this.state.printNavigationItems(searchValue);
|
||||
}
|
||||
|
||||
public printScriptLexicalStructureItems() {
|
||||
this.state.printScriptLexicalStructureItems();
|
||||
public printNavigationBar() {
|
||||
this.state.printNavigationBar();
|
||||
}
|
||||
|
||||
public printReferences() {
|
||||
|
||||
+54
-24
@@ -127,7 +127,7 @@ namespace Utils {
|
||||
export function memoize<T extends Function>(f: T): T {
|
||||
const cache: { [idx: string]: any } = {};
|
||||
|
||||
return <any>(function () {
|
||||
return <any>(function() {
|
||||
const key = Array.prototype.join.call(arguments);
|
||||
const cachedResult = cache[key];
|
||||
if (cachedResult) {
|
||||
@@ -619,7 +619,7 @@ namespace Harness {
|
||||
export const getCurrentDirectory = () => "";
|
||||
export const args = () => <string[]>[];
|
||||
export const getExecutingFilePath = () => "";
|
||||
export const exit = (exitCode: number) => {};
|
||||
export const exit = (exitCode: number) => { };
|
||||
|
||||
export let log = (s: string) => console.log(s);
|
||||
|
||||
@@ -836,7 +836,7 @@ namespace Harness {
|
||||
}
|
||||
|
||||
if (!libFileNameSourceFileMap[fileName]) {
|
||||
libFileNameSourceFileMap[fileName] = createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest);
|
||||
libFileNameSourceFileMap[fileName] = createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest);
|
||||
}
|
||||
return libFileNameSourceFileMap[fileName];
|
||||
}
|
||||
@@ -865,13 +865,23 @@ namespace Harness {
|
||||
// Local get canonical file name function, that depends on passed in parameter for useCaseSensitiveFileNames
|
||||
const getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
|
||||
|
||||
const fileMap: ts.FileMap<ts.SourceFile> = ts.createFileMap<ts.SourceFile>();
|
||||
let realPathMap: ts.FileMap<string>;
|
||||
const fileMap: ts.FileMap<() => ts.SourceFile> = ts.createFileMap<() => ts.SourceFile>();
|
||||
for (const file of inputFiles) {
|
||||
if (file.content !== undefined) {
|
||||
const fileName = ts.normalizePath(file.unitName);
|
||||
const sourceFile = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget);
|
||||
const path = ts.toPath(file.unitName, currentDirectory, getCanonicalFileName);
|
||||
fileMap.set(path, sourceFile);
|
||||
if (file.fileOptions && file.fileOptions["symlink"]) {
|
||||
const link = file.fileOptions["symlink"];
|
||||
const linkPath = ts.toPath(link, currentDirectory, getCanonicalFileName);
|
||||
if (!realPathMap) {
|
||||
realPathMap = ts.createFileMap<string>();
|
||||
}
|
||||
realPathMap.set(linkPath, fileName);
|
||||
fileMap.set(path, (): ts.SourceFile => { throw new Error("Symlinks should always be resolved to a realpath first"); });
|
||||
}
|
||||
const sourceFile = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget);
|
||||
fileMap.set(path, () => sourceFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -879,7 +889,7 @@ namespace Harness {
|
||||
fileName = ts.normalizePath(fileName);
|
||||
const path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
if (fileMap.contains(path)) {
|
||||
return fileMap.get(path);
|
||||
return fileMap.get(path)();
|
||||
}
|
||||
else if (fileName === fourslashFileName) {
|
||||
const tsFn = "tests/cases/fourslash/" + fourslashFileName;
|
||||
@@ -900,6 +910,20 @@ namespace Harness {
|
||||
|
||||
|
||||
return {
|
||||
getDefaultTypeDirectiveNames: (path: string) => {
|
||||
const results: string[] = [];
|
||||
fileMap.forEachValue((key, value) => {
|
||||
const rx = /node_modules\/@types\/(\w+)/;
|
||||
const typeNameResult = rx.exec(key);
|
||||
if (typeNameResult) {
|
||||
const typeName = typeNameResult[1];
|
||||
if (results.indexOf(typeName) < 0) {
|
||||
results.push(typeName);
|
||||
}
|
||||
}
|
||||
});
|
||||
return results;
|
||||
},
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
getSourceFile,
|
||||
getDefaultLibFileName,
|
||||
@@ -908,11 +932,16 @@ namespace Harness {
|
||||
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
|
||||
getNewLine: () => newLine,
|
||||
fileExists: fileName => {
|
||||
return fileMap.contains(ts.toPath(fileName, currentDirectory, getCanonicalFileName));
|
||||
const path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
return fileMap.contains(path) || (realPathMap && realPathMap.contains(path));
|
||||
},
|
||||
readFile: (fileName: string): string => {
|
||||
return fileMap.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)).getText();
|
||||
}
|
||||
return fileMap.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName))().getText();
|
||||
},
|
||||
realpath: realPathMap && ((f: string) => {
|
||||
const path = ts.toPath(f, currentDirectory, getCanonicalFileName);
|
||||
return realPathMap.contains(path) ? realPathMap.get(path) : path;
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
@@ -933,7 +962,9 @@ namespace Harness {
|
||||
{ name: "libFiles", type: "string" },
|
||||
{ name: "noErrorTruncation", type: "boolean" },
|
||||
{ name: "suppressOutputPathCheck", type: "boolean" },
|
||||
{ name: "noImplicitReferences", type: "boolean" }
|
||||
{ name: "noImplicitReferences", type: "boolean" },
|
||||
{ name: "currentDirectory", type: "string" },
|
||||
{ name: "symlink", type: "string" }
|
||||
];
|
||||
|
||||
let optionsIndex: ts.Map<ts.CommandLineOption>;
|
||||
@@ -988,6 +1019,7 @@ namespace Harness {
|
||||
export interface TestFile {
|
||||
unitName: string;
|
||||
content: string;
|
||||
fileOptions?: any;
|
||||
}
|
||||
|
||||
export interface CompilationOutput {
|
||||
@@ -1425,10 +1457,8 @@ namespace Harness {
|
||||
// Comment line, check for global/file @options and record them
|
||||
optionRegex.lastIndex = 0;
|
||||
const metaDataName = testMetaData[1].toLowerCase();
|
||||
if (metaDataName === "filename") {
|
||||
currentFileOptions[testMetaData[1]] = testMetaData[2];
|
||||
}
|
||||
else {
|
||||
currentFileOptions[testMetaData[1]] = testMetaData[2];
|
||||
if (metaDataName !== "filename") {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1436,12 +1466,12 @@ namespace Harness {
|
||||
if (currentFileName) {
|
||||
// Store result file
|
||||
const newTestFile = {
|
||||
content: currentFileContent,
|
||||
name: currentFileName,
|
||||
fileOptions: currentFileOptions,
|
||||
originalFilePath: fileName,
|
||||
references: refs
|
||||
};
|
||||
content: currentFileContent,
|
||||
name: currentFileName,
|
||||
fileOptions: currentFileOptions,
|
||||
originalFilePath: fileName,
|
||||
references: refs
|
||||
};
|
||||
testUnitData.push(newTestFile);
|
||||
|
||||
// Reset local data
|
||||
@@ -1539,10 +1569,10 @@ namespace Harness {
|
||||
|
||||
function baselinePath(fileName: string, type: string, baselineFolder: string, subfolder?: string) {
|
||||
if (subfolder !== undefined) {
|
||||
return Harness.userSpecifiedRoot + baselineFolder + "/" + subfolder + "/" + type + "/" + fileName;
|
||||
return Harness.userSpecifiedRoot + baselineFolder + "/" + subfolder + "/" + type + "/" + fileName;
|
||||
}
|
||||
else {
|
||||
return Harness.userSpecifiedRoot + baselineFolder + "/" + type + "/" + fileName;
|
||||
return Harness.userSpecifiedRoot + baselineFolder + "/" + type + "/" + fileName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1611,7 +1641,7 @@ namespace Harness {
|
||||
}
|
||||
|
||||
function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string, descriptionForDescribe: string) {
|
||||
const encoded_actual = Utils.encodeString(actual);
|
||||
const encoded_actual = Utils.encodeString(actual);
|
||||
if (expected != encoded_actual) {
|
||||
// Overwrite & issue error
|
||||
const errMsg = "The baseline file " + relativeFileName + " has changed.";
|
||||
|
||||
@@ -182,6 +182,7 @@ namespace Harness.LanguageService {
|
||||
class NativeLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceHost {
|
||||
getCompilationSettings() { return this.settings; }
|
||||
getCancellationToken() { return this.cancellationToken; }
|
||||
getDirectories(path: string): string[] { return []; }
|
||||
getCurrentDirectory(): string { return ""; }
|
||||
getDefaultLibFileName(): string { return Harness.Compiler.defaultLibFileName; }
|
||||
getScriptFileNames(): string[] { return this.getFilenames(); }
|
||||
@@ -268,6 +269,7 @@ namespace Harness.LanguageService {
|
||||
getCompilationSettings(): string { return JSON.stringify(this.nativeHost.getCompilationSettings()); }
|
||||
getCancellationToken(): ts.HostCancellationToken { return this.nativeHost.getCancellationToken(); }
|
||||
getCurrentDirectory(): string { return this.nativeHost.getCurrentDirectory(); }
|
||||
getDirectories(path: string) { return this.nativeHost.getDirectories(path); }
|
||||
getDefaultLibFileName(): string { return this.nativeHost.getDefaultLibFileName(); }
|
||||
getScriptFileNames(): string { return JSON.stringify(this.nativeHost.getScriptFileNames()); }
|
||||
getScriptSnapshot(fileName: string): ts.ScriptSnapshotShim {
|
||||
@@ -600,6 +602,10 @@ namespace Harness.LanguageService {
|
||||
return this.host.getCurrentDirectory();
|
||||
}
|
||||
|
||||
getDirectories(path: string): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
readDirectory(path: string, extension?: string): string[] {
|
||||
throw new Error("Not implemented Yet.");
|
||||
}
|
||||
@@ -641,6 +647,14 @@ namespace Harness.LanguageService {
|
||||
|
||||
startGroup(): void {
|
||||
}
|
||||
|
||||
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any {
|
||||
return setTimeout(callback, ms, args);
|
||||
}
|
||||
|
||||
clearTimeout(timeoutId: any): void {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
}
|
||||
|
||||
export class ServerLanguageServiceAdapter implements LanguageServiceAdapter {
|
||||
|
||||
+20
-19
@@ -1,6 +1,6 @@
|
||||
declare var require: any, process: any;
|
||||
var fs: any = require('fs');
|
||||
var path: any = require('path');
|
||||
declare const require: any, process: any;
|
||||
const fs: any = require("fs");
|
||||
const path: any = require("path");
|
||||
|
||||
function instrumentForRecording(fn: string, tscPath: string) {
|
||||
instrument(tscPath, `
|
||||
@@ -14,31 +14,31 @@ ts.sys = Playback.wrapSystem(ts.sys);
|
||||
ts.sys.startReplay("${ logFilename }");`);
|
||||
}
|
||||
|
||||
function instrument(tscPath: string, prepareCode: string, cleanupCode: string = '') {
|
||||
var bak = tscPath + '.bak';
|
||||
function instrument(tscPath: string, prepareCode: string, cleanupCode = "") {
|
||||
const bak = `${tscPath}.bak`;
|
||||
fs.exists(bak, (backupExists: boolean) => {
|
||||
var filename = tscPath;
|
||||
let filename = tscPath;
|
||||
if (backupExists) {
|
||||
filename = bak;
|
||||
}
|
||||
|
||||
fs.readFile(filename, 'utf-8', (err: any, tscContent: string) => {
|
||||
fs.readFile(filename, "utf-8", (err: any, tscContent: string) => {
|
||||
if (err) throw err;
|
||||
|
||||
fs.writeFile(bak, tscContent, (err: any) => {
|
||||
if (err) throw err;
|
||||
|
||||
fs.readFile(path.resolve(path.dirname(tscPath) + '/loggedIO.js'), 'utf-8', (err: any, loggerContent: string) => {
|
||||
fs.readFile(path.resolve(path.dirname(tscPath) + "/loggedIO.js"), "utf-8", (err: any, loggerContent: string) => {
|
||||
if (err) throw err;
|
||||
|
||||
var invocationLine = 'ts.executeCommandLine(ts.sys.args);';
|
||||
var index1 = tscContent.indexOf(invocationLine);
|
||||
const invocationLine = "ts.executeCommandLine(ts.sys.args);";
|
||||
const index1 = tscContent.indexOf(invocationLine);
|
||||
if (index1 < 0) {
|
||||
throw new Error("Could not find " + invocationLine);
|
||||
throw new Error(`Could not find ${invocationLine}`);
|
||||
}
|
||||
|
||||
var index2 = index1 + invocationLine.length;
|
||||
var newContent = tscContent.substr(0, index1) + loggerContent + prepareCode + invocationLine + cleanupCode + tscContent.substr(index2) + '\r\n';
|
||||
const index2 = index1 + invocationLine.length;
|
||||
const newContent = tscContent.substr(0, index1) + loggerContent + prepareCode + invocationLine + cleanupCode + tscContent.substr(index2) + "\r\n";
|
||||
fs.writeFile(tscPath, newContent);
|
||||
});
|
||||
});
|
||||
@@ -46,15 +46,16 @@ function instrument(tscPath: string, prepareCode: string, cleanupCode: string =
|
||||
});
|
||||
}
|
||||
|
||||
var isJson = (arg: string) => arg.indexOf(".json") > 0;
|
||||
const isJson = (arg: string) => arg.indexOf(".json") > 0;
|
||||
|
||||
var record = process.argv.indexOf('record');
|
||||
var tscPath = process.argv[process.argv.length - 1];
|
||||
const record = process.argv.indexOf("record");
|
||||
const tscPath = process.argv[process.argv.length - 1];
|
||||
if (record >= 0) {
|
||||
console.log('Instrumenting ' + tscPath + ' for recording');
|
||||
console.log(`Instrumenting ${tscPath} for recording`);
|
||||
instrumentForRecording(process.argv[record + 1], tscPath);
|
||||
} else if (process.argv.some(isJson)) {
|
||||
var filename = process.argv.filter(isJson)[0];
|
||||
}
|
||||
else if (process.argv.some(isJson)) {
|
||||
const filename = process.argv.filter(isJson)[0];
|
||||
instrumentForReplay(filename, tscPath);
|
||||
}
|
||||
|
||||
|
||||
Vendored
+8
-17
@@ -4,13 +4,13 @@ interface Map<K, V> {
|
||||
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
|
||||
get(key: K): V | undefined;
|
||||
has(key: K): boolean;
|
||||
set(key: K, value?: V): Map<K, V>;
|
||||
set(key: K, value?: V): this;
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
new (): Map<any, any>;
|
||||
new <K, V>(): Map<K, V>;
|
||||
new <K, V>(entries?: [K, V][]): Map<K, V>;
|
||||
readonly prototype: Map<any, any>;
|
||||
}
|
||||
declare var Map: MapConstructor;
|
||||
@@ -20,51 +20,42 @@ interface WeakMap<K, V> {
|
||||
delete(key: K): boolean;
|
||||
get(key: K): V | undefined;
|
||||
has(key: K): boolean;
|
||||
set(key: K, value?: V): WeakMap<K, V>;
|
||||
|
||||
set(key: K, value?: V): this;
|
||||
}
|
||||
|
||||
interface WeakMapConstructor {
|
||||
new (): WeakMap<any, any>;
|
||||
new <K, V>(): WeakMap<K, V>;
|
||||
new <K, V>(entries?: [K, V][]): WeakMap<K, V>;
|
||||
readonly prototype: WeakMap<any, any>;
|
||||
}
|
||||
declare var WeakMap: WeakMapConstructor;
|
||||
|
||||
interface Set<T> {
|
||||
add(value: T): Set<T>;
|
||||
add(value: T): this;
|
||||
clear(): void;
|
||||
delete(value: T): boolean;
|
||||
entries(): IterableIterator<[T, T]>;
|
||||
forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
|
||||
has(value: T): boolean;
|
||||
keys(): IterableIterator<T>;
|
||||
readonly size: number;
|
||||
values(): IterableIterator<T>;
|
||||
[Symbol.iterator]():IterableIterator<T>;
|
||||
readonly [Symbol.toStringTag]: "Set";
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
new (): Set<any>;
|
||||
new <T>(): Set<T>;
|
||||
new <T>(iterable: Iterable<T>): Set<T>;
|
||||
new <T>(values?: T[]): Set<T>;
|
||||
readonly prototype: Set<any>;
|
||||
}
|
||||
declare var Set: SetConstructor;
|
||||
|
||||
interface WeakSet<T> {
|
||||
add(value: T): WeakSet<T>;
|
||||
add(value: T): this;
|
||||
clear(): void;
|
||||
delete(value: T): boolean;
|
||||
has(value: T): boolean;
|
||||
readonly [Symbol.toStringTag]: "WeakSet";
|
||||
}
|
||||
|
||||
interface WeakSetConstructor {
|
||||
new (): WeakSet<any>;
|
||||
new <T>(): WeakSet<T>;
|
||||
new <T>(iterable: Iterable<T>): WeakSet<T>;
|
||||
new <T>(values?: T[]): WeakSet<T>;
|
||||
readonly prototype: WeakSet<any>;
|
||||
}
|
||||
declare var WeakSet: WeakSetConstructor;
|
||||
Vendored
+14
-6
@@ -16,12 +16,12 @@ interface Array<T> {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: T) => boolean, thisArg?: any): number | undefined;
|
||||
findIndex(predicate: (value: T) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Returns the this object after filling the section identified by start and end with value
|
||||
@@ -31,7 +31,7 @@ interface Array<T> {
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* length+end.
|
||||
*/
|
||||
fill(value: T, start?: number, end?: number): T[];
|
||||
fill(value: T, start?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Returns the this object after copying a section of the array identified by start and end
|
||||
@@ -42,7 +42,7 @@ interface Array<T> {
|
||||
* is treated as length+end.
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
*/
|
||||
copyWithin(target: number, start: number, end?: number): T[];
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
}
|
||||
|
||||
interface ArrayConstructor {
|
||||
@@ -402,6 +402,14 @@ interface String {
|
||||
*/
|
||||
endsWith(searchString: string, endPosition?: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns the String value result of normalizing the string into the normalization form
|
||||
* named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
|
||||
* @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
|
||||
* is "NFC"
|
||||
*/
|
||||
normalize(form: "NFC" | "NFD" | "NFKC" | "NFKD"): string;
|
||||
|
||||
/**
|
||||
* Returns the String value result of normalizing the string into the normalization form
|
||||
* named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
|
||||
@@ -485,4 +493,4 @@ interface StringConstructor {
|
||||
* @param substitutions A set of substitution values.
|
||||
*/
|
||||
raw(template: TemplateStringsArray, ...substitutions: any[]): string;
|
||||
}
|
||||
}
|
||||
Vendored
+55
-3
@@ -1,8 +1,16 @@
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A method that returns the default iterator for an object. Called by the semantics of the
|
||||
* for-of statement.
|
||||
*/
|
||||
readonly iterator: symbol;
|
||||
}
|
||||
|
||||
interface IteratorResult<T> {
|
||||
done: boolean;
|
||||
value?: T;
|
||||
value: T;
|
||||
}
|
||||
|
||||
interface Iterator<T> {
|
||||
@@ -11,11 +19,18 @@ interface Iterator<T> {
|
||||
throw?(e?: any): IteratorResult<T>;
|
||||
}
|
||||
|
||||
interface Iterable<T> { }
|
||||
interface Iterable<T> {
|
||||
[Symbol.iterator](): Iterator<T>;
|
||||
}
|
||||
|
||||
interface IterableIterator<T> extends Iterator<T> { }
|
||||
interface IterableIterator<T> extends Iterator<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface Array<T> {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -48,7 +63,13 @@ interface ArrayConstructor {
|
||||
from<T>(iterable: Iterable<T>): Array<T>;
|
||||
}
|
||||
|
||||
interface IArguments {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<any>;
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
[Symbol.iterator](): IterableIterator<[K,V]>;
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
keys(): IterableIterator<K>;
|
||||
values(): IterableIterator<V>;
|
||||
@@ -64,6 +85,23 @@ interface WeakMapConstructor {
|
||||
new <K, V>(iterable: Iterable<[K, V]>): WeakMap<K, V>;
|
||||
}
|
||||
|
||||
interface Set<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
entries(): IterableIterator<[T, T]>;
|
||||
keys(): IterableIterator<T>;
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
new <T>(iterable: Iterable<T>): Set<T>;
|
||||
}
|
||||
|
||||
interface WeakSet<T> { }
|
||||
|
||||
interface WeakSetConstructor {
|
||||
new <T>(iterable: Iterable<T>): WeakSet<T>;
|
||||
}
|
||||
|
||||
interface Promise<T> { }
|
||||
|
||||
interface PromiseConstructor {
|
||||
@@ -88,11 +126,17 @@ declare namespace Reflect {
|
||||
function enumerate(target: any): IterableIterator<any>;
|
||||
}
|
||||
|
||||
interface String {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit integer values. The contents are initialized to 0. If the requested
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int8Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -124,6 +168,7 @@ interface Int8ArrayConstructor {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -155,6 +200,7 @@ interface Uint8ArrayConstructor {
|
||||
* If the requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8ClampedArray {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -189,6 +235,7 @@ interface Uint8ClampedArrayConstructor {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int16Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -222,6 +269,7 @@ interface Int16ArrayConstructor {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint16Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -253,6 +301,7 @@ interface Uint16ArrayConstructor {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -284,6 +333,7 @@ interface Int32ArrayConstructor {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -315,6 +365,7 @@ interface Uint32ArrayConstructor {
|
||||
* of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
@@ -346,6 +397,7 @@ interface Float32ArrayConstructor {
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float64Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
|
||||
Vendored
+8
-37
@@ -13,12 +13,6 @@ interface SymbolConstructor {
|
||||
*/
|
||||
readonly isConcatSpreadable: symbol;
|
||||
|
||||
/**
|
||||
* A method that returns the default iterator for an object. Called by the semantics of the
|
||||
* for-of statement.
|
||||
*/
|
||||
readonly iterator: symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that matches the regular expression against a string. Called
|
||||
* by the String.prototype.match method.
|
||||
@@ -73,9 +67,6 @@ interface Symbol {
|
||||
}
|
||||
|
||||
interface Array<T> {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an object whose properties have the value 'true'
|
||||
* when they will be absent when used in a 'with' statement.
|
||||
@@ -116,7 +107,6 @@ interface Date {
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
[Symbol.iterator]():IterableIterator<[K,V]>;
|
||||
readonly [Symbol.toStringTag]: "Map";
|
||||
}
|
||||
|
||||
@@ -124,6 +114,14 @@ interface WeakMap<K, V>{
|
||||
readonly [Symbol.toStringTag]: "WeakMap";
|
||||
}
|
||||
|
||||
interface Set<T> {
|
||||
readonly [Symbol.toStringTag]: "Set";
|
||||
}
|
||||
|
||||
interface WeakSet<T> {
|
||||
readonly [Symbol.toStringTag]: "WeakSet";
|
||||
}
|
||||
|
||||
interface JSON {
|
||||
readonly [Symbol.toStringTag]: "JSON";
|
||||
}
|
||||
@@ -143,21 +141,6 @@ interface GeneratorFunction extends Function {
|
||||
readonly [Symbol.toStringTag]: "GeneratorFunction";
|
||||
}
|
||||
|
||||
interface IArguments {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<any>;
|
||||
}
|
||||
|
||||
interface Iterator<T> { }
|
||||
|
||||
interface Iterable<T> {
|
||||
[Symbol.iterator](): Iterator<T>;
|
||||
}
|
||||
|
||||
interface IterableIterator<T> extends Iterator<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface Math {
|
||||
readonly [Symbol.toStringTag]: "Math";
|
||||
}
|
||||
@@ -223,9 +206,6 @@ interface RegExpConstructor {
|
||||
}
|
||||
|
||||
interface String {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
|
||||
/**
|
||||
* Matches a string an object that supports being matched against, and returns an array containing the results of that search.
|
||||
* @param matcher An object that supports being matched against.
|
||||
@@ -279,7 +259,6 @@ interface DataView {
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int8Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "Int8Array";
|
||||
}
|
||||
|
||||
@@ -288,7 +267,6 @@ interface Int8Array {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "UInt8Array";
|
||||
}
|
||||
|
||||
@@ -297,7 +275,6 @@ interface Uint8Array {
|
||||
* If the requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8ClampedArray {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "Uint8ClampedArray";
|
||||
}
|
||||
|
||||
@@ -306,7 +283,6 @@ interface Uint8ClampedArray {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int16Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "Int16Array";
|
||||
}
|
||||
|
||||
@@ -315,7 +291,6 @@ interface Int16Array {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint16Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "Uint16Array";
|
||||
}
|
||||
|
||||
@@ -324,7 +299,6 @@ interface Uint16Array {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "Int32Array";
|
||||
}
|
||||
|
||||
@@ -333,7 +307,6 @@ interface Int32Array {
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "Uint32Array";
|
||||
}
|
||||
|
||||
@@ -342,7 +315,6 @@ interface Uint32Array {
|
||||
* of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "Float32Array";
|
||||
}
|
||||
|
||||
@@ -351,6 +323,5 @@ interface Float32Array {
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float64Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
readonly [Symbol.toStringTag]: "Float64Array";
|
||||
}
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
/// <reference path="lib.es2016.d.ts" />
|
||||
/// <reference path="lib.es2017.object.d.ts" />
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
interface ObjectConstructor {
|
||||
/**
|
||||
* Returns an array of values of the enumerable properties of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
values<T>(o: { [s: string]: T }): T[];
|
||||
values(o: any): any[];
|
||||
/**
|
||||
* Returns an array of key/values of the enumerable properties of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
entries<T>(o: { [s: string]: T }): [string, T][];
|
||||
entries(o: any): [string, any][];
|
||||
}
|
||||
Vendored
+60
-75
@@ -864,6 +864,7 @@ declare const RegExp: RegExpConstructor;
|
||||
interface Error {
|
||||
name: string;
|
||||
message: string;
|
||||
stack?: string;
|
||||
}
|
||||
|
||||
interface ErrorConstructor {
|
||||
@@ -948,38 +949,22 @@ interface JSON {
|
||||
* If a member contains nested objects, the nested objects are transformed before the parent object is.
|
||||
*/
|
||||
parse(text: string, reviver?: (key: any, value: any) => any): any;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
*/
|
||||
stringify(value: any): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer A function that transforms the results.
|
||||
*/
|
||||
stringify(value: any, replacer: (key: string, value: any) => any): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer Array that transforms the results.
|
||||
*/
|
||||
stringify(value: any, replacer: any[]): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer A function that transforms the results.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
||||
*/
|
||||
stringify(value: any, replacer: (key: string, value: any) => any, space: string | number): string;
|
||||
stringify(value: any, replacer?: (key: string, value: any) => any, space?: string | number): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer Array that transforms the results.
|
||||
* @param replacer An array of strings and numbers that acts as a white list for selecting the object properties that will be stringified.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
||||
*/
|
||||
stringify(value: any, replacer: any[], space: string | number): string;
|
||||
stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
|
||||
*/
|
||||
@@ -1139,7 +1124,7 @@ interface Array<T> {
|
||||
* Sorts an array.
|
||||
* @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order.
|
||||
*/
|
||||
sort(compareFn?: (a: T, b: T) => number): T[];
|
||||
sort(compareFn?: (a: T, b: T) => number): this;
|
||||
/**
|
||||
* Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
|
||||
* @param start The zero-based location in the array from which to start removing elements.
|
||||
@@ -1481,7 +1466,7 @@ interface Int8Array {
|
||||
* is treated as length+end.
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
*/
|
||||
copyWithin(target: number, start: number, end?: number): Int8Array;
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -1501,7 +1486,7 @@ interface Int8Array {
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* length+end.
|
||||
*/
|
||||
fill(value: number, start?: number, end?: number): Int8Array;
|
||||
fill(value: number, start?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Returns the elements of an array that meet the condition specified in a callback function.
|
||||
@@ -1527,12 +1512,12 @@ interface Int8Array {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -1670,7 +1655,7 @@ interface Int8Array {
|
||||
* @param compareFn The name of the function used to determine the order of the elements. If
|
||||
* omitted, the elements are sorted in ascending, ASCII character order.
|
||||
*/
|
||||
sort(compareFn?: (a: number, b: number) => number): Int8Array;
|
||||
sort(compareFn?: (a: number, b: number) => number): this;
|
||||
|
||||
/**
|
||||
* Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements
|
||||
@@ -1754,7 +1739,7 @@ interface Uint8Array {
|
||||
* is treated as length+end.
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
*/
|
||||
copyWithin(target: number, start: number, end?: number): Uint8Array;
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -1774,7 +1759,7 @@ interface Uint8Array {
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* length+end.
|
||||
*/
|
||||
fill(value: number, start?: number, end?: number): Uint8Array;
|
||||
fill(value: number, start?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Returns the elements of an array that meet the condition specified in a callback function.
|
||||
@@ -1800,12 +1785,12 @@ interface Uint8Array {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -1943,7 +1928,7 @@ interface Uint8Array {
|
||||
* @param compareFn The name of the function used to determine the order of the elements. If
|
||||
* omitted, the elements are sorted in ascending, ASCII character order.
|
||||
*/
|
||||
sort(compareFn?: (a: number, b: number) => number): Uint8Array;
|
||||
sort(compareFn?: (a: number, b: number) => number): this;
|
||||
|
||||
/**
|
||||
* Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements
|
||||
@@ -2028,7 +2013,7 @@ interface Uint8ClampedArray {
|
||||
* is treated as length+end.
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
*/
|
||||
copyWithin(target: number, start: number, end?: number): Uint8ClampedArray;
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -2048,7 +2033,7 @@ interface Uint8ClampedArray {
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* length+end.
|
||||
*/
|
||||
fill(value: number, start?: number, end?: number): Uint8ClampedArray;
|
||||
fill(value: number, start?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Returns the elements of an array that meet the condition specified in a callback function.
|
||||
@@ -2074,12 +2059,12 @@ interface Uint8ClampedArray {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -2217,7 +2202,7 @@ interface Uint8ClampedArray {
|
||||
* @param compareFn The name of the function used to determine the order of the elements. If
|
||||
* omitted, the elements are sorted in ascending, ASCII character order.
|
||||
*/
|
||||
sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray;
|
||||
sort(compareFn?: (a: number, b: number) => number): this;
|
||||
|
||||
/**
|
||||
* Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements
|
||||
@@ -2301,7 +2286,7 @@ interface Int16Array {
|
||||
* is treated as length+end.
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
*/
|
||||
copyWithin(target: number, start: number, end?: number): Int16Array;
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -2321,7 +2306,7 @@ interface Int16Array {
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* length+end.
|
||||
*/
|
||||
fill(value: number, start?: number, end?: number): Int16Array;
|
||||
fill(value: number, start?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Returns the elements of an array that meet the condition specified in a callback function.
|
||||
@@ -2347,12 +2332,12 @@ interface Int16Array {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -2490,7 +2475,7 @@ interface Int16Array {
|
||||
* @param compareFn The name of the function used to determine the order of the elements. If
|
||||
* omitted, the elements are sorted in ascending, ASCII character order.
|
||||
*/
|
||||
sort(compareFn?: (a: number, b: number) => number): Int16Array;
|
||||
sort(compareFn?: (a: number, b: number) => number): this;
|
||||
|
||||
/**
|
||||
* Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements
|
||||
@@ -2575,7 +2560,7 @@ interface Uint16Array {
|
||||
* is treated as length+end.
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
*/
|
||||
copyWithin(target: number, start: number, end?: number): Uint16Array;
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -2595,7 +2580,7 @@ interface Uint16Array {
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* length+end.
|
||||
*/
|
||||
fill(value: number, start?: number, end?: number): Uint16Array;
|
||||
fill(value: number, start?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Returns the elements of an array that meet the condition specified in a callback function.
|
||||
@@ -2621,12 +2606,12 @@ interface Uint16Array {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -2764,7 +2749,7 @@ interface Uint16Array {
|
||||
* @param compareFn The name of the function used to determine the order of the elements. If
|
||||
* omitted, the elements are sorted in ascending, ASCII character order.
|
||||
*/
|
||||
sort(compareFn?: (a: number, b: number) => number): Uint16Array;
|
||||
sort(compareFn?: (a: number, b: number) => number): this;
|
||||
|
||||
/**
|
||||
* Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements
|
||||
@@ -2848,7 +2833,7 @@ interface Int32Array {
|
||||
* is treated as length+end.
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
*/
|
||||
copyWithin(target: number, start: number, end?: number): Int32Array;
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -2868,7 +2853,7 @@ interface Int32Array {
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* length+end.
|
||||
*/
|
||||
fill(value: number, start?: number, end?: number): Int32Array;
|
||||
fill(value: number, start?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Returns the elements of an array that meet the condition specified in a callback function.
|
||||
@@ -2894,12 +2879,12 @@ interface Int32Array {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -3037,7 +3022,7 @@ interface Int32Array {
|
||||
* @param compareFn The name of the function used to determine the order of the elements. If
|
||||
* omitted, the elements are sorted in ascending, ASCII character order.
|
||||
*/
|
||||
sort(compareFn?: (a: number, b: number) => number): Int32Array;
|
||||
sort(compareFn?: (a: number, b: number) => number): this;
|
||||
|
||||
/**
|
||||
* Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements
|
||||
@@ -3121,7 +3106,7 @@ interface Uint32Array {
|
||||
* is treated as length+end.
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
*/
|
||||
copyWithin(target: number, start: number, end?: number): Uint32Array;
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -3141,7 +3126,7 @@ interface Uint32Array {
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* length+end.
|
||||
*/
|
||||
fill(value: number, start?: number, end?: number): Uint32Array;
|
||||
fill(value: number, start?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Returns the elements of an array that meet the condition specified in a callback function.
|
||||
@@ -3167,12 +3152,12 @@ interface Uint32Array {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -3310,7 +3295,7 @@ interface Uint32Array {
|
||||
* @param compareFn The name of the function used to determine the order of the elements. If
|
||||
* omitted, the elements are sorted in ascending, ASCII character order.
|
||||
*/
|
||||
sort(compareFn?: (a: number, b: number) => number): Uint32Array;
|
||||
sort(compareFn?: (a: number, b: number) => number): this;
|
||||
|
||||
/**
|
||||
* Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements
|
||||
@@ -3394,7 +3379,7 @@ interface Float32Array {
|
||||
* is treated as length+end.
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
*/
|
||||
copyWithin(target: number, start: number, end?: number): Float32Array;
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -3414,7 +3399,7 @@ interface Float32Array {
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* length+end.
|
||||
*/
|
||||
fill(value: number, start?: number, end?: number): Float32Array;
|
||||
fill(value: number, start?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Returns the elements of an array that meet the condition specified in a callback function.
|
||||
@@ -3440,12 +3425,12 @@ interface Float32Array {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -3583,7 +3568,7 @@ interface Float32Array {
|
||||
* @param compareFn The name of the function used to determine the order of the elements. If
|
||||
* omitted, the elements are sorted in ascending, ASCII character order.
|
||||
*/
|
||||
sort(compareFn?: (a: number, b: number) => number): Float32Array;
|
||||
sort(compareFn?: (a: number, b: number) => number): this;
|
||||
|
||||
/**
|
||||
* Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements
|
||||
@@ -3668,7 +3653,7 @@ interface Float64Array {
|
||||
* is treated as length+end.
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
*/
|
||||
copyWithin(target: number, start: number, end?: number): Float64Array;
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -3688,7 +3673,7 @@ interface Float64Array {
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* length+end.
|
||||
*/
|
||||
fill(value: number, start?: number, end?: number): Float64Array;
|
||||
fill(value: number, start?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Returns the elements of an array that meet the condition specified in a callback function.
|
||||
@@ -3714,12 +3699,12 @@ interface Float64Array {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
|
||||
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -3857,7 +3842,7 @@ interface Float64Array {
|
||||
* @param compareFn The name of the function used to determine the order of the elements. If
|
||||
* omitted, the elements are sorted in ascending, ASCII character order.
|
||||
*/
|
||||
sort(compareFn?: (a: number, b: number) => number): Float64Array;
|
||||
sort(compareFn?: (a: number, b: number) => number): this;
|
||||
|
||||
/**
|
||||
* Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements
|
||||
|
||||
+168
-155
@@ -1,5 +1,5 @@
|
||||
/// <reference path="session.ts" />
|
||||
|
||||
|
||||
namespace ts.server {
|
||||
|
||||
export interface SessionClientHost extends LanguageServiceHost {
|
||||
@@ -21,27 +21,26 @@ namespace ts.server {
|
||||
|
||||
export class SessionClient implements LanguageService {
|
||||
private sequence: number = 0;
|
||||
private fileMapping: ts.Map<string> = {};
|
||||
private lineMaps: ts.Map<number[]> = {};
|
||||
private messages: string[] = [];
|
||||
private lastRenameEntry: RenameEntry;
|
||||
|
||||
|
||||
constructor(private host: SessionClientHost) {
|
||||
}
|
||||
|
||||
public onMessage(message: string): void {
|
||||
public onMessage(message: string): void {
|
||||
this.messages.push(message);
|
||||
}
|
||||
|
||||
private writeMessage(message: string): void {
|
||||
private writeMessage(message: string): void {
|
||||
this.host.writeMessage(message);
|
||||
}
|
||||
|
||||
private getLineMap(fileName: string): number[] {
|
||||
var lineMap = ts.lookUp(this.lineMaps, fileName);
|
||||
private getLineMap(fileName: string): number[] {
|
||||
let lineMap = ts.lookUp(this.lineMaps, fileName);
|
||||
if (!lineMap) {
|
||||
var scriptSnapshot = this.host.getScriptSnapshot(fileName);
|
||||
lineMap = this.lineMaps[fileName] = ts.computeLineStarts(scriptSnapshot.getText(0, scriptSnapshot.getLength()));
|
||||
const scriptSnapshot = this.host.getScriptSnapshot(fileName);
|
||||
lineMap = this.lineMaps[fileName] = ts.computeLineStarts(scriptSnapshot.getText(0, scriptSnapshot.getLength()));
|
||||
}
|
||||
return lineMap;
|
||||
}
|
||||
@@ -51,7 +50,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private positionToOneBasedLineOffset(fileName: string, position: number): protocol.Location {
|
||||
var lineOffset = ts.computeLineAndCharacterOfPosition(this.getLineMap(fileName), position);
|
||||
const lineOffset = ts.computeLineAndCharacterOfPosition(this.getLineMap(fileName), position);
|
||||
return {
|
||||
line: lineOffset.line + 1,
|
||||
offset: lineOffset.character + 1
|
||||
@@ -59,8 +58,8 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private convertCodeEditsToTextChange(fileName: string, codeEdit: protocol.CodeEdit): ts.TextChange {
|
||||
var start = this.lineOffsetToPosition(fileName, codeEdit.start);
|
||||
var end = this.lineOffsetToPosition(fileName, codeEdit.end);
|
||||
const start = this.lineOffsetToPosition(fileName, codeEdit.start);
|
||||
const end = this.lineOffsetToPosition(fileName, codeEdit.end);
|
||||
|
||||
return {
|
||||
span: ts.createTextSpanFromBounds(start, end),
|
||||
@@ -69,12 +68,13 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private processRequest<T extends protocol.Request>(command: string, args?: any): T {
|
||||
var request: protocol.Request = {
|
||||
seq: this.sequence++,
|
||||
const request: protocol.Request = {
|
||||
seq: this.sequence,
|
||||
type: "request",
|
||||
arguments: args,
|
||||
command
|
||||
};
|
||||
this.sequence++;
|
||||
|
||||
this.writeMessage(JSON.stringify(request));
|
||||
|
||||
@@ -82,34 +82,29 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private processResponse<T extends protocol.Response>(request: protocol.Request): T {
|
||||
var lastMessage = this.messages.shift();
|
||||
Debug.assert(!!lastMessage, "Did not receive any responses.");
|
||||
|
||||
// Read the content length
|
||||
var contentLengthPrefix = "Content-Length: ";
|
||||
var lines = lastMessage.split("\r\n");
|
||||
Debug.assert(lines.length >= 2, "Malformed response: Expected 3 lines in the response.");
|
||||
|
||||
var contentLengthText = lines[0];
|
||||
Debug.assert(contentLengthText.indexOf(contentLengthPrefix) === 0, "Malformed response: Response text did not contain content-length header.");
|
||||
var contentLength = parseInt(contentLengthText.substring(contentLengthPrefix.length));
|
||||
|
||||
// Read the body
|
||||
var responseBody = lines[2];
|
||||
|
||||
// Verify content length
|
||||
Debug.assert(responseBody.length + 1 === contentLength, "Malformed response: Content length did not match the response's body length.");
|
||||
|
||||
try {
|
||||
var response: T = JSON.parse(responseBody);
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error("Malformed response: Failed to parse server response: " + lastMessage + ". \r\n Error details: " + e.message);
|
||||
let foundResponseMessage = false;
|
||||
let lastMessage: string;
|
||||
let response: T;
|
||||
while (!foundResponseMessage) {
|
||||
lastMessage = this.messages.shift();
|
||||
Debug.assert(!!lastMessage, "Did not receive any responses.");
|
||||
const responseBody = processMessage(lastMessage);
|
||||
try {
|
||||
response = JSON.parse(responseBody);
|
||||
// the server may emit events before emitting the response. We
|
||||
// want to ignore these events for testing purpose.
|
||||
if (response.type === "response") {
|
||||
foundResponseMessage = true;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error("Malformed response: Failed to parse server response: " + lastMessage + ". \r\n Error details: " + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
// verify the sequence numbers
|
||||
Debug.assert(response.request_seq === request.seq, "Malformed response: response sequence number did not match request sequence number.");
|
||||
|
||||
|
||||
// unmarshal errors
|
||||
if (!response.success) {
|
||||
throw new Error("Error " + response.message);
|
||||
@@ -118,15 +113,33 @@ namespace ts.server {
|
||||
Debug.assert(!!response.body, "Malformed response: Unexpected empty response body.");
|
||||
|
||||
return response;
|
||||
|
||||
function processMessage(message: string) {
|
||||
// Read the content length
|
||||
const contentLengthPrefix = "Content-Length: ";
|
||||
const lines = message.split("\r\n");
|
||||
Debug.assert(lines.length >= 2, "Malformed response: Expected 3 lines in the response.");
|
||||
|
||||
const contentLengthText = lines[0];
|
||||
Debug.assert(contentLengthText.indexOf(contentLengthPrefix) === 0, "Malformed response: Response text did not contain content-length header.");
|
||||
const contentLength = parseInt(contentLengthText.substring(contentLengthPrefix.length));
|
||||
|
||||
// Read the body
|
||||
const responseBody = lines[2];
|
||||
|
||||
// Verify content length
|
||||
Debug.assert(responseBody.length + 1 === contentLength, "Malformed response: Content length did not match the response's body length.");
|
||||
return responseBody;
|
||||
}
|
||||
}
|
||||
|
||||
openFile(fileName: string, content?: string, scriptKindName?: "TS" | "JS" | "TSX" | "JSX"): void {
|
||||
var args: protocol.OpenRequestArgs = { file: fileName, fileContent: content, scriptKindName };
|
||||
openFile(fileName: string, content?: string, scriptKindName?: "TS" | "JS" | "TSX" | "JSX"): void {
|
||||
const args: protocol.OpenRequestArgs = { file: fileName, fileContent: content, scriptKindName };
|
||||
this.processRequest(CommandNames.Open, args);
|
||||
}
|
||||
|
||||
closeFile(fileName: string): void {
|
||||
var args: protocol.FileRequestArgs = { file: fileName };
|
||||
const args: protocol.FileRequestArgs = { file: fileName };
|
||||
this.processRequest(CommandNames.Close, args);
|
||||
}
|
||||
|
||||
@@ -134,10 +147,10 @@ namespace ts.server {
|
||||
// clear the line map after an edit
|
||||
this.lineMaps[fileName] = undefined;
|
||||
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, start);
|
||||
var endLineOffset = this.positionToOneBasedLineOffset(fileName, end);
|
||||
const lineOffset = this.positionToOneBasedLineOffset(fileName, start);
|
||||
const endLineOffset = this.positionToOneBasedLineOffset(fileName, end);
|
||||
|
||||
var args: protocol.ChangeRequestArgs = {
|
||||
const args: protocol.ChangeRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
@@ -150,18 +163,18 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo {
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.FileLocationRequestArgs = {
|
||||
const lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
const args: protocol.FileLocationRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.QuickInfoRequest>(CommandNames.Quickinfo, args);
|
||||
var response = this.processResponse<protocol.QuickInfoResponse>(request);
|
||||
const request = this.processRequest<protocol.QuickInfoRequest>(CommandNames.Quickinfo, args);
|
||||
const response = this.processResponse<protocol.QuickInfoResponse>(request);
|
||||
|
||||
var start = this.lineOffsetToPosition(fileName, response.body.start);
|
||||
var end = this.lineOffsetToPosition(fileName, response.body.end);
|
||||
const start = this.lineOffsetToPosition(fileName, response.body.start);
|
||||
const end = this.lineOffsetToPosition(fileName, response.body.end);
|
||||
|
||||
return {
|
||||
kind: response.body.kind,
|
||||
@@ -173,68 +186,68 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getProjectInfo(fileName: string, needFileNameList: boolean): protocol.ProjectInfo {
|
||||
var args: protocol.ProjectInfoRequestArgs = {
|
||||
const args: protocol.ProjectInfoRequestArgs = {
|
||||
file: fileName,
|
||||
needFileNameList: needFileNameList
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.ProjectInfoRequest>(CommandNames.ProjectInfo, args);
|
||||
var response = this.processResponse<protocol.ProjectInfoResponse>(request);
|
||||
const request = this.processRequest<protocol.ProjectInfoRequest>(CommandNames.ProjectInfo, args);
|
||||
const response = this.processResponse<protocol.ProjectInfoResponse>(request);
|
||||
|
||||
return {
|
||||
configFileName: response.body.configFileName,
|
||||
fileNames: response.body.fileNames
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getCompletionsAtPosition(fileName: string, position: number): CompletionInfo {
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.CompletionsRequestArgs = {
|
||||
const lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
const args: protocol.CompletionsRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
prefix: undefined
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.CompletionsRequest>(CommandNames.Completions, args);
|
||||
var response = this.processResponse<protocol.CompletionsResponse>(request);
|
||||
const request = this.processRequest<protocol.CompletionsRequest>(CommandNames.Completions, args);
|
||||
const response = this.processResponse<protocol.CompletionsResponse>(request);
|
||||
|
||||
return {
|
||||
return {
|
||||
isMemberCompletion: false,
|
||||
isNewIdentifierLocation: false,
|
||||
entries: response.body
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails {
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.CompletionDetailsRequestArgs = {
|
||||
const lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
const args: protocol.CompletionDetailsRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
entryNames: [entryName]
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.CompletionDetailsRequest>(CommandNames.CompletionDetails, args);
|
||||
var response = this.processResponse<protocol.CompletionDetailsResponse>(request);
|
||||
const request = this.processRequest<protocol.CompletionDetailsRequest>(CommandNames.CompletionDetails, args);
|
||||
const response = this.processResponse<protocol.CompletionDetailsResponse>(request);
|
||||
Debug.assert(response.body.length === 1, "Unexpected length of completion details response body.");
|
||||
return response.body[0];
|
||||
}
|
||||
|
||||
getNavigateToItems(searchValue: string): NavigateToItem[] {
|
||||
var args: protocol.NavtoRequestArgs = {
|
||||
const args: protocol.NavtoRequestArgs = {
|
||||
searchValue,
|
||||
file: this.host.getScriptFileNames()[0]
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.NavtoRequest>(CommandNames.Navto, args);
|
||||
var response = this.processResponse<protocol.NavtoResponse>(request);
|
||||
const request = this.processRequest<protocol.NavtoRequest>(CommandNames.Navto, args);
|
||||
const response = this.processResponse<protocol.NavtoResponse>(request);
|
||||
|
||||
return response.body.map(entry => {
|
||||
var fileName = entry.file;
|
||||
var start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
var end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
|
||||
const fileName = entry.file;
|
||||
const start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
const end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
|
||||
return {
|
||||
name: entry.name,
|
||||
containerName: entry.containerName || "",
|
||||
@@ -250,9 +263,9 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getFormattingEditsForRange(fileName: string, start: number, end: number, options: ts.FormatCodeOptions): ts.TextChange[] {
|
||||
var startLineOffset = this.positionToOneBasedLineOffset(fileName, start);
|
||||
var endLineOffset = this.positionToOneBasedLineOffset(fileName, end);
|
||||
var args: protocol.FormatRequestArgs = {
|
||||
const startLineOffset = this.positionToOneBasedLineOffset(fileName, start);
|
||||
const endLineOffset = this.positionToOneBasedLineOffset(fileName, end);
|
||||
const args: protocol.FormatRequestArgs = {
|
||||
file: fileName,
|
||||
line: startLineOffset.line,
|
||||
offset: startLineOffset.offset,
|
||||
@@ -261,10 +274,10 @@ namespace ts.server {
|
||||
};
|
||||
|
||||
// TODO: handle FormatCodeOptions
|
||||
var request = this.processRequest<protocol.FormatRequest>(CommandNames.Format, args);
|
||||
var response = this.processResponse<protocol.FormatResponse>(request);
|
||||
const request = this.processRequest<protocol.FormatRequest>(CommandNames.Format, args);
|
||||
const response = this.processResponse<protocol.FormatResponse>(request);
|
||||
|
||||
return response.body.map(entry=> this.convertCodeEditsToTextChange(fileName, entry));
|
||||
return response.body.map(entry => this.convertCodeEditsToTextChange(fileName, entry));
|
||||
}
|
||||
|
||||
getFormattingEditsForDocument(fileName: string, options: ts.FormatCodeOptions): ts.TextChange[] {
|
||||
@@ -272,8 +285,8 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): ts.TextChange[] {
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.FormatOnKeyRequestArgs = {
|
||||
const lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
const args: protocol.FormatOnKeyRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
@@ -281,27 +294,27 @@ namespace ts.server {
|
||||
};
|
||||
|
||||
// TODO: handle FormatCodeOptions
|
||||
var request = this.processRequest<protocol.FormatOnKeyRequest>(CommandNames.Formatonkey, args);
|
||||
var response = this.processResponse<protocol.FormatResponse>(request);
|
||||
const request = this.processRequest<protocol.FormatOnKeyRequest>(CommandNames.Formatonkey, args);
|
||||
const response = this.processResponse<protocol.FormatResponse>(request);
|
||||
|
||||
return response.body.map(entry=> this.convertCodeEditsToTextChange(fileName, entry));
|
||||
return response.body.map(entry => this.convertCodeEditsToTextChange(fileName, entry));
|
||||
}
|
||||
|
||||
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] {
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.FileLocationRequestArgs = {
|
||||
const lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
const args: protocol.FileLocationRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.DefinitionRequest>(CommandNames.Definition, args);
|
||||
var response = this.processResponse<protocol.DefinitionResponse>(request);
|
||||
const request = this.processRequest<protocol.DefinitionRequest>(CommandNames.Definition, args);
|
||||
const response = this.processResponse<protocol.DefinitionResponse>(request);
|
||||
|
||||
return response.body.map(entry => {
|
||||
var fileName = entry.file;
|
||||
var start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
var end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
const fileName = entry.file;
|
||||
const start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
const end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
return {
|
||||
containerKind: "",
|
||||
containerName: "",
|
||||
@@ -314,20 +327,20 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] {
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.FileLocationRequestArgs = {
|
||||
const lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
const args: protocol.FileLocationRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.TypeDefinitionRequest>(CommandNames.TypeDefinition, args);
|
||||
var response = this.processResponse<protocol.TypeDefinitionResponse>(request);
|
||||
const request = this.processRequest<protocol.TypeDefinitionRequest>(CommandNames.TypeDefinition, args);
|
||||
const response = this.processResponse<protocol.TypeDefinitionResponse>(request);
|
||||
|
||||
return response.body.map(entry => {
|
||||
var fileName = entry.file;
|
||||
var start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
var end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
const fileName = entry.file;
|
||||
const start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
const end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
return {
|
||||
containerKind: "",
|
||||
containerName: "",
|
||||
@@ -339,26 +352,26 @@ namespace ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
findReferences(fileName: string, position: number): ReferencedSymbol[]{
|
||||
findReferences(fileName: string, position: number): ReferencedSymbol[] {
|
||||
// Not yet implemented.
|
||||
return [];
|
||||
}
|
||||
|
||||
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.FileLocationRequestArgs = {
|
||||
const lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
const args: protocol.FileLocationRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.ReferencesRequest>(CommandNames.References, args);
|
||||
var response = this.processResponse<protocol.ReferencesResponse>(request);
|
||||
const request = this.processRequest<protocol.ReferencesRequest>(CommandNames.References, args);
|
||||
const response = this.processResponse<protocol.ReferencesResponse>(request);
|
||||
|
||||
return response.body.refs.map(entry => {
|
||||
var fileName = entry.file;
|
||||
var start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
var end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
const fileName = entry.file;
|
||||
const start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
const end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
return {
|
||||
fileName: fileName,
|
||||
textSpan: ts.createTextSpanFromBounds(start, end),
|
||||
@@ -384,8 +397,8 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getRenameInfo(fileName: string, position: number, findInStrings?: boolean, findInComments?: boolean): RenameInfo {
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.RenameRequestArgs = {
|
||||
const lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
const args: protocol.RenameRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
@@ -393,14 +406,14 @@ namespace ts.server {
|
||||
findInComments
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.RenameRequest>(CommandNames.Rename, args);
|
||||
var response = this.processResponse<protocol.RenameResponse>(request);
|
||||
var locations: RenameLocation[] = [];
|
||||
const request = this.processRequest<protocol.RenameRequest>(CommandNames.Rename, args);
|
||||
const response = this.processResponse<protocol.RenameResponse>(request);
|
||||
const locations: RenameLocation[] = [];
|
||||
response.body.locs.map((entry: protocol.SpanGroup) => {
|
||||
var fileName = entry.file;
|
||||
const fileName = entry.file;
|
||||
entry.locs.map((loc: protocol.TextSpan) => {
|
||||
var start = this.lineOffsetToPosition(fileName, loc.start);
|
||||
var end = this.lineOffsetToPosition(fileName, loc.end);
|
||||
const start = this.lineOffsetToPosition(fileName, loc.start);
|
||||
const end = this.lineOffsetToPosition(fileName, loc.end);
|
||||
locations.push({
|
||||
textSpan: ts.createTextSpanFromBounds(start, end),
|
||||
fileName: fileName
|
||||
@@ -444,7 +457,7 @@ namespace ts.server {
|
||||
text: item.text,
|
||||
kind: item.kind,
|
||||
kindModifiers: item.kindModifiers || "",
|
||||
spans: item.spans.map(span=> createTextSpanFromBounds(this.lineOffsetToPosition(fileName, span.start), this.lineOffsetToPosition(fileName, span.end))),
|
||||
spans: item.spans.map(span => createTextSpanFromBounds(this.lineOffsetToPosition(fileName, span.start), this.lineOffsetToPosition(fileName, span.end))),
|
||||
childItems: this.decodeNavigationBarItems(item.childItems, fileName),
|
||||
indent: 0,
|
||||
bolded: false,
|
||||
@@ -453,12 +466,12 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getNavigationBarItems(fileName: string): NavigationBarItem[] {
|
||||
var args: protocol.FileRequestArgs = {
|
||||
const args: protocol.FileRequestArgs = {
|
||||
file: fileName
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.NavBarRequest>(CommandNames.NavBar, args);
|
||||
var response = this.processResponse<protocol.NavBarResponse>(request);
|
||||
const request = this.processRequest<protocol.NavBarRequest>(CommandNames.NavBar, args);
|
||||
const response = this.processResponse<protocol.NavBarResponse>(request);
|
||||
|
||||
return this.decodeNavigationBarItems(response.body, fileName);
|
||||
}
|
||||
@@ -472,26 +485,26 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems {
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.SignatureHelpRequestArgs = {
|
||||
const lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
const args: protocol.SignatureHelpRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.SignatureHelpRequest>(CommandNames.SignatureHelp, args);
|
||||
var response = this.processResponse<protocol.SignatureHelpResponse>(request);
|
||||
|
||||
|
||||
const request = this.processRequest<protocol.SignatureHelpRequest>(CommandNames.SignatureHelp, args);
|
||||
const response = this.processResponse<protocol.SignatureHelpResponse>(request);
|
||||
|
||||
if (!response.body) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var helpItems: protocol.SignatureHelpItems = response.body;
|
||||
var span = helpItems.applicableSpan;
|
||||
var start = this.lineOffsetToPosition(fileName, span.start);
|
||||
var end = this.lineOffsetToPosition(fileName, span.end);
|
||||
|
||||
var result: SignatureHelpItems = {
|
||||
const helpItems: protocol.SignatureHelpItems = response.body;
|
||||
const span = helpItems.applicableSpan;
|
||||
const start = this.lineOffsetToPosition(fileName, span.start);
|
||||
const end = this.lineOffsetToPosition(fileName, span.end);
|
||||
|
||||
const result: SignatureHelpItems = {
|
||||
items: helpItems.items,
|
||||
applicableSpan: {
|
||||
start: start,
|
||||
@@ -499,26 +512,26 @@ namespace ts.server {
|
||||
},
|
||||
selectedItemIndex: helpItems.selectedItemIndex,
|
||||
argumentIndex: helpItems.argumentIndex,
|
||||
argumentCount: helpItems.argumentCount,
|
||||
}
|
||||
argumentCount: helpItems.argumentCount,
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.FileLocationRequestArgs = {
|
||||
const lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
const args: protocol.FileLocationRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.OccurrencesRequest>(CommandNames.Occurrences, args);
|
||||
var response = this.processResponse<protocol.OccurrencesResponse>(request);
|
||||
const request = this.processRequest<protocol.OccurrencesRequest>(CommandNames.Occurrences, args);
|
||||
const response = this.processResponse<protocol.OccurrencesResponse>(request);
|
||||
|
||||
return response.body.map(entry => {
|
||||
var fileName = entry.file;
|
||||
var start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
var end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
const fileName = entry.file;
|
||||
const start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
const end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
return {
|
||||
fileName,
|
||||
textSpan: ts.createTextSpanFromBounds(start, end),
|
||||
@@ -528,17 +541,17 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] {
|
||||
let { line, offset } = this.positionToOneBasedLineOffset(fileName, position);
|
||||
let args: protocol.DocumentHighlightsRequestArgs = { file: fileName, line, offset, filesToSearch };
|
||||
const { line, offset } = this.positionToOneBasedLineOffset(fileName, position);
|
||||
const args: protocol.DocumentHighlightsRequestArgs = { file: fileName, line, offset, filesToSearch };
|
||||
|
||||
let request = this.processRequest<protocol.DocumentHighlightsRequest>(CommandNames.DocumentHighlights, args);
|
||||
let response = this.processResponse<protocol.DocumentHighlightsResponse>(request);
|
||||
const request = this.processRequest<protocol.DocumentHighlightsRequest>(CommandNames.DocumentHighlights, args);
|
||||
const response = this.processResponse<protocol.DocumentHighlightsResponse>(request);
|
||||
|
||||
let self = this;
|
||||
const self = this;
|
||||
return response.body.map(convertToDocumentHighlights);
|
||||
|
||||
function convertToDocumentHighlights(item: ts.server.protocol.DocumentHighlightsItem): ts.DocumentHighlights {
|
||||
let { file, highlightSpans } = item;
|
||||
const { file, highlightSpans } = item;
|
||||
|
||||
return {
|
||||
fileName: file,
|
||||
@@ -546,8 +559,8 @@ namespace ts.server {
|
||||
};
|
||||
|
||||
function convertHighlightSpan(span: ts.server.protocol.HighlightSpan): ts.HighlightSpan {
|
||||
let start = self.lineOffsetToPosition(file, span.start);
|
||||
let end = self.lineOffsetToPosition(file, span.end);
|
||||
const start = self.lineOffsetToPosition(file, span.start);
|
||||
const end = self.lineOffsetToPosition(file, span.end);
|
||||
return {
|
||||
textSpan: ts.createTextSpanFromBounds(start, end),
|
||||
kind: span.kind
|
||||
@@ -561,31 +574,31 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[] {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
|
||||
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[] {
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.FileLocationRequestArgs = {
|
||||
const lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
const args: protocol.FileLocationRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.BraceRequest>(CommandNames.Brace, args);
|
||||
var response = this.processResponse<protocol.BraceResponse>(request);
|
||||
const request = this.processRequest<protocol.BraceRequest>(CommandNames.Brace, args);
|
||||
const response = this.processResponse<protocol.BraceResponse>(request);
|
||||
|
||||
return response.body.map(entry => {
|
||||
var start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
var end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
const start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
const end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
return {
|
||||
start: start,
|
||||
length: end - start,
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace ts.server {
|
||||
children: ScriptInfo[] = []; // files referenced by this file
|
||||
defaultProject: Project; // project to use by default for file
|
||||
fileWatcher: FileWatcher;
|
||||
formatCodeOptions = ts.clone(CompilerService.defaultFormatCodeOptions);
|
||||
formatCodeOptions = ts.clone(CompilerService.getDefaultFormatCodeOptions(this.host));
|
||||
path: Path;
|
||||
scriptKind: ScriptKind;
|
||||
|
||||
@@ -533,7 +533,7 @@ namespace ts.server {
|
||||
// number becomes 0 for a watcher, then we should close it.
|
||||
directoryWatchersRefCount: ts.Map<number> = {};
|
||||
hostConfiguration: HostConfiguration;
|
||||
timerForDetectingProjectFileListChanges: Map<NodeJS.Timer> = {};
|
||||
timerForDetectingProjectFileListChanges: Map<any> = {};
|
||||
|
||||
constructor(public host: ServerHost, public psLogger: Logger, public eventHandler?: ProjectServiceEventHandler) {
|
||||
// ts.disableIncrementalParsing = true;
|
||||
@@ -542,7 +542,7 @@ namespace ts.server {
|
||||
|
||||
addDefaultHostConfiguration() {
|
||||
this.hostConfiguration = {
|
||||
formatCodeOptions: ts.clone(CompilerService.defaultFormatCodeOptions),
|
||||
formatCodeOptions: ts.clone(CompilerService.getDefaultFormatCodeOptions(this.host)),
|
||||
hostInfo: "Unknown host"
|
||||
};
|
||||
}
|
||||
@@ -593,9 +593,9 @@ namespace ts.server {
|
||||
|
||||
startTimerForDetectingProjectFileListChanges(project: Project) {
|
||||
if (this.timerForDetectingProjectFileListChanges[project.projectFilename]) {
|
||||
clearTimeout(this.timerForDetectingProjectFileListChanges[project.projectFilename]);
|
||||
this.host.clearTimeout(this.timerForDetectingProjectFileListChanges[project.projectFilename]);
|
||||
}
|
||||
this.timerForDetectingProjectFileListChanges[project.projectFilename] = setTimeout(
|
||||
this.timerForDetectingProjectFileListChanges[project.projectFilename] = this.host.setTimeout(
|
||||
() => this.handleProjectFileListChanges(project),
|
||||
250
|
||||
);
|
||||
@@ -1096,12 +1096,12 @@ namespace ts.server {
|
||||
* @param filename is absolute pathname
|
||||
* @param fileContent is a known version of the file content that is more up to date than the one on disk
|
||||
*/
|
||||
openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind) {
|
||||
this.openOrUpdateConfiguredProjectForFile(fileName);
|
||||
openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind): { configFileName?: string, configFileErrors?: Diagnostic[] } {
|
||||
const { configFileName, configFileErrors } = this.openOrUpdateConfiguredProjectForFile(fileName);
|
||||
const info = this.openFile(fileName, /*openedByClient*/ true, fileContent, scriptKind);
|
||||
this.addOpenFile(info);
|
||||
this.printProjects();
|
||||
return info;
|
||||
return { configFileName, configFileErrors };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1109,7 +1109,7 @@ namespace ts.server {
|
||||
* we first detect if there is already a configured project created for it: if so, we re-read
|
||||
* the tsconfig file content and update the project; otherwise we create a new one.
|
||||
*/
|
||||
openOrUpdateConfiguredProjectForFile(fileName: string) {
|
||||
openOrUpdateConfiguredProjectForFile(fileName: string): { configFileName?: string, configFileErrors?: Diagnostic[] } {
|
||||
const searchPath = ts.normalizePath(getDirectoryPath(fileName));
|
||||
this.log("Search path: " + searchPath, "Info");
|
||||
const configFileName = this.findConfigFile(searchPath);
|
||||
@@ -1119,11 +1119,16 @@ namespace ts.server {
|
||||
if (!project) {
|
||||
const configResult = this.openConfigFile(configFileName, fileName);
|
||||
if (!configResult.success) {
|
||||
this.log("Error opening config file " + configFileName + " " + configResult.errorMsg);
|
||||
return { configFileName, configFileErrors: configResult.errors };
|
||||
}
|
||||
else {
|
||||
// even if opening config file was successful, it could still
|
||||
// contain errors that were tolerated.
|
||||
this.log("Opened configuration file " + configFileName, "Info");
|
||||
this.configuredProjects.push(configResult.project);
|
||||
if (configResult.errors && configResult.errors.length > 0) {
|
||||
return { configFileName, configFileErrors: configResult.errors };
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1133,6 +1138,7 @@ namespace ts.server {
|
||||
else {
|
||||
this.log("No config files found.");
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1222,24 +1228,25 @@ namespace ts.server {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
configFileToProjectOptions(configFilename: string): { succeeded: boolean, projectOptions?: ProjectOptions, error?: ProjectOpenResult } {
|
||||
configFileToProjectOptions(configFilename: string): { succeeded: boolean, projectOptions?: ProjectOptions, errors?: Diagnostic[] } {
|
||||
configFilename = ts.normalizePath(configFilename);
|
||||
// file references will be relative to dirPath (or absolute)
|
||||
const dirPath = ts.getDirectoryPath(configFilename);
|
||||
const contents = this.host.readFile(configFilename);
|
||||
const rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = ts.parseConfigFileTextToJson(configFilename, contents);
|
||||
if (rawConfig.error) {
|
||||
return { succeeded: false, error: rawConfig.error };
|
||||
return { succeeded: false, errors: [rawConfig.error] };
|
||||
}
|
||||
else {
|
||||
const parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath, /*existingOptions*/ {}, configFilename);
|
||||
Debug.assert(!!parsedCommandLine.fileNames);
|
||||
|
||||
if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) {
|
||||
return { succeeded: false, error: { errorMsg: "tsconfig option errors" } };
|
||||
return { succeeded: false, errors: parsedCommandLine.errors };
|
||||
}
|
||||
else if (parsedCommandLine.fileNames.length === 0) {
|
||||
return { succeeded: false, error: { errorMsg: "no files found" } };
|
||||
const error = createCompilerDiagnostic(Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename);
|
||||
return { succeeded: false, errors: [error] };
|
||||
}
|
||||
else {
|
||||
const projectOptions: ProjectOptions = {
|
||||
@@ -1252,20 +1259,21 @@ namespace ts.server {
|
||||
|
||||
}
|
||||
|
||||
openConfigFile(configFilename: string, clientFileName?: string): ProjectOpenResult {
|
||||
const { succeeded, projectOptions, error } = this.configFileToProjectOptions(configFilename);
|
||||
openConfigFile(configFilename: string, clientFileName?: string): { success: boolean, project?: Project, errors?: Diagnostic[] } {
|
||||
const { succeeded, projectOptions, errors } = this.configFileToProjectOptions(configFilename);
|
||||
if (!succeeded) {
|
||||
return error;
|
||||
return { success: false, errors };
|
||||
}
|
||||
else {
|
||||
const project = this.createProject(configFilename, projectOptions);
|
||||
let errors: Diagnostic[];
|
||||
for (const rootFilename of projectOptions.files) {
|
||||
if (this.host.fileExists(rootFilename)) {
|
||||
const info = this.openFile(rootFilename, /*openedByClient*/ clientFileName == rootFilename);
|
||||
project.addRoot(info);
|
||||
}
|
||||
else {
|
||||
return { errorMsg: "specified file " + rootFilename + " not found" };
|
||||
(errors || (errors = [])).push(createCompilerDiagnostic(Diagnostics.File_0_not_found, rootFilename));
|
||||
}
|
||||
}
|
||||
project.finishGraph();
|
||||
@@ -1276,7 +1284,7 @@ namespace ts.server {
|
||||
path => this.directoryWatchedForSourceFilesChanged(project, path),
|
||||
/*recursive*/ true
|
||||
);
|
||||
return { success: true, project: project };
|
||||
return { success: true, project: project, errors };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1286,13 +1294,13 @@ namespace ts.server {
|
||||
this.removeProject(project);
|
||||
}
|
||||
else {
|
||||
const { succeeded, projectOptions, error } = this.configFileToProjectOptions(project.projectFilename);
|
||||
const { succeeded, projectOptions, errors } = this.configFileToProjectOptions(project.projectFilename);
|
||||
if (!succeeded) {
|
||||
return error;
|
||||
return errors;
|
||||
}
|
||||
else {
|
||||
const oldFileNames = project.compilerService.host.roots.map(info => info.fileName);
|
||||
const newFileNames = projectOptions.files;
|
||||
const newFileNames = ts.filter(projectOptions.files, f => this.host.fileExists(f));
|
||||
const fileNamesToRemove = oldFileNames.filter(f => newFileNames.indexOf(f) < 0);
|
||||
const fileNamesToAdd = newFileNames.filter(f => oldFileNames.indexOf(f) < 0);
|
||||
|
||||
@@ -1374,23 +1382,25 @@ namespace ts.server {
|
||||
return ts.isExternalModule(sourceFile);
|
||||
}
|
||||
|
||||
static defaultFormatCodeOptions: ts.FormatCodeOptions = {
|
||||
IndentSize: 4,
|
||||
TabSize: 4,
|
||||
NewLineCharacter: ts.sys ? ts.sys.newLine : "\n",
|
||||
ConvertTabsToSpaces: true,
|
||||
IndentStyle: ts.IndentStyle.Smart,
|
||||
InsertSpaceAfterCommaDelimiter: true,
|
||||
InsertSpaceAfterSemicolonInForStatements: true,
|
||||
InsertSpaceBeforeAndAfterBinaryOperators: true,
|
||||
InsertSpaceAfterKeywordsInControlFlowStatements: true,
|
||||
InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false,
|
||||
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false,
|
||||
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false,
|
||||
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false,
|
||||
PlaceOpenBraceOnNewLineForFunctions: false,
|
||||
PlaceOpenBraceOnNewLineForControlBlocks: false,
|
||||
};
|
||||
static getDefaultFormatCodeOptions(host: ServerHost): ts.FormatCodeOptions {
|
||||
return ts.clone({
|
||||
IndentSize: 4,
|
||||
TabSize: 4,
|
||||
NewLineCharacter: host.newLine || "\n",
|
||||
ConvertTabsToSpaces: true,
|
||||
IndentStyle: ts.IndentStyle.Smart,
|
||||
InsertSpaceAfterCommaDelimiter: true,
|
||||
InsertSpaceAfterSemicolonInForStatements: true,
|
||||
InsertSpaceBeforeAndAfterBinaryOperators: true,
|
||||
InsertSpaceAfterKeywordsInControlFlowStatements: true,
|
||||
InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false,
|
||||
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false,
|
||||
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false,
|
||||
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false,
|
||||
PlaceOpenBraceOnNewLineForFunctions: false,
|
||||
PlaceOpenBraceOnNewLineForControlBlocks: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export interface LineCollection {
|
||||
|
||||
Vendored
+83
-57
@@ -1,54 +1,54 @@
|
||||
/**
|
||||
* Declaration module describing the TypeScript Server protocol
|
||||
/**
|
||||
* Declaration module describing the TypeScript Server protocol
|
||||
*/
|
||||
declare namespace ts.server.protocol {
|
||||
/**
|
||||
* A TypeScript Server message
|
||||
/**
|
||||
* A TypeScript Server message
|
||||
*/
|
||||
export interface Message {
|
||||
/**
|
||||
* Sequence number of the message
|
||||
/**
|
||||
* Sequence number of the message
|
||||
*/
|
||||
seq: number;
|
||||
|
||||
/**
|
||||
* One of "request", "response", or "event"
|
||||
* One of "request", "response", or "event"
|
||||
*/
|
||||
type: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Client-initiated request message
|
||||
/**
|
||||
* Client-initiated request message
|
||||
*/
|
||||
export interface Request extends Message {
|
||||
/**
|
||||
* The command to execute
|
||||
* The command to execute
|
||||
*/
|
||||
command: string;
|
||||
|
||||
/**
|
||||
* Object containing arguments for the command
|
||||
/**
|
||||
* Object containing arguments for the command
|
||||
*/
|
||||
arguments?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to reload the project structure for all the opened files
|
||||
* Request to reload the project structure for all the opened files
|
||||
*/
|
||||
export interface ReloadProjectsRequest extends Message {
|
||||
}
|
||||
|
||||
/**
|
||||
* Server-initiated event message
|
||||
/**
|
||||
* Server-initiated event message
|
||||
*/
|
||||
export interface Event extends Message {
|
||||
/**
|
||||
* Name of event
|
||||
/**
|
||||
* Name of event
|
||||
*/
|
||||
event: string;
|
||||
|
||||
/**
|
||||
* Event-specific information
|
||||
/**
|
||||
* Event-specific information
|
||||
*/
|
||||
body?: any;
|
||||
}
|
||||
@@ -62,18 +62,18 @@ declare namespace ts.server.protocol {
|
||||
*/
|
||||
request_seq: number;
|
||||
|
||||
/**
|
||||
* Outcome of the request.
|
||||
/**
|
||||
* Outcome of the request.
|
||||
*/
|
||||
success: boolean;
|
||||
|
||||
/**
|
||||
/**
|
||||
* The command requested.
|
||||
*/
|
||||
command: string;
|
||||
|
||||
/**
|
||||
* Contains error message if success === false.
|
||||
/**
|
||||
* Contains error message if success === false.
|
||||
*/
|
||||
message?: string;
|
||||
|
||||
@@ -83,7 +83,7 @@ declare namespace ts.server.protocol {
|
||||
body?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Arguments for FileRequest messages.
|
||||
*/
|
||||
export interface FileRequestArgs {
|
||||
@@ -93,7 +93,7 @@ declare namespace ts.server.protocol {
|
||||
file: string;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Arguments for ProjectInfoRequest request.
|
||||
*/
|
||||
export interface ProjectInfoRequestArgs extends FileRequestArgs {
|
||||
@@ -110,7 +110,7 @@ declare namespace ts.server.protocol {
|
||||
arguments: ProjectInfoRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Response message body for "projectInfo" request
|
||||
*/
|
||||
export interface ProjectInfo {
|
||||
@@ -125,7 +125,7 @@ declare namespace ts.server.protocol {
|
||||
fileNames?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Response message for "projectInfo" request
|
||||
*/
|
||||
export interface ProjectInfoResponse extends Response {
|
||||
@@ -144,12 +144,12 @@ declare namespace ts.server.protocol {
|
||||
* (file, line, character offset), where line and character offset are 1-based.
|
||||
*/
|
||||
export interface FileLocationRequestArgs extends FileRequestArgs {
|
||||
/**
|
||||
/**
|
||||
* The line number for the request (1-based).
|
||||
*/
|
||||
line: number;
|
||||
|
||||
/**
|
||||
/**
|
||||
* The character offset (on the line) for the request (1-based).
|
||||
*/
|
||||
offset: number;
|
||||
@@ -216,7 +216,7 @@ declare namespace ts.server.protocol {
|
||||
* Object found in response messages defining a span of text in a specific source file.
|
||||
*/
|
||||
export interface FileSpan extends TextSpan {
|
||||
/**
|
||||
/**
|
||||
* File containing text span.
|
||||
*/
|
||||
file: string;
|
||||
@@ -300,14 +300,14 @@ declare namespace ts.server.protocol {
|
||||
*/
|
||||
lineText: string;
|
||||
|
||||
/**
|
||||
/**
|
||||
* True if reference is a write location, false otherwise.
|
||||
*/
|
||||
isWriteAccess: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* The body of a "references" response message.
|
||||
* The body of a "references" response message.
|
||||
*/
|
||||
export interface ReferencesResponseBody {
|
||||
/**
|
||||
@@ -325,7 +325,7 @@ declare namespace ts.server.protocol {
|
||||
*/
|
||||
symbolStartOffset: number;
|
||||
|
||||
/**
|
||||
/**
|
||||
* The full display name of the symbol.
|
||||
*/
|
||||
symbolDisplayString: string;
|
||||
@@ -355,7 +355,7 @@ declare namespace ts.server.protocol {
|
||||
}
|
||||
|
||||
/**
|
||||
* Information about the item to be renamed.
|
||||
* Information about the item to be renamed.
|
||||
*/
|
||||
export interface RenameInfo {
|
||||
/**
|
||||
@@ -373,7 +373,7 @@ declare namespace ts.server.protocol {
|
||||
*/
|
||||
displayName: string;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Full display name of item to be renamed.
|
||||
*/
|
||||
fullDisplayName: string;
|
||||
@@ -383,7 +383,7 @@ declare namespace ts.server.protocol {
|
||||
*/
|
||||
kind: string;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Optional modifiers for the kind (such as 'public').
|
||||
*/
|
||||
kindModifiers: string;
|
||||
@@ -477,7 +477,7 @@ declare namespace ts.server.protocol {
|
||||
*/
|
||||
export interface ConfigureRequestArguments {
|
||||
|
||||
/**
|
||||
/**
|
||||
* Information about the host, for example 'Emacs 24.4' or
|
||||
* 'Sublime Text version 3075'
|
||||
*/
|
||||
@@ -495,7 +495,7 @@ declare namespace ts.server.protocol {
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure request; value of command field is "configure". Specifies
|
||||
* Configure request; value of command field is "configure". Specifies
|
||||
* host information, such as host type, tab size, and indent size.
|
||||
*/
|
||||
export interface ConfigureRequest extends Request {
|
||||
@@ -514,8 +514,8 @@ declare namespace ts.server.protocol {
|
||||
*/
|
||||
export interface OpenRequestArgs extends FileRequestArgs {
|
||||
/**
|
||||
* Used when a version of the file content is known to be more up to date than the one on disk.
|
||||
* Then the known content will be used upon opening instead of the disk copy
|
||||
* Used when a version of the file content is known to be more up to date than the one on disk.
|
||||
* Then the known content will be used upon opening instead of the disk copy
|
||||
*/
|
||||
fileContent?: string;
|
||||
/**
|
||||
@@ -756,7 +756,7 @@ declare namespace ts.server.protocol {
|
||||
* Optional modifiers for the kind (such as 'public').
|
||||
*/
|
||||
kindModifiers: string;
|
||||
/**
|
||||
/**
|
||||
* A string that is used for comparing completion items so that they can be ordered. This
|
||||
* is often the same as the name but may be different in certain circumstances.
|
||||
*/
|
||||
@@ -799,7 +799,7 @@ declare namespace ts.server.protocol {
|
||||
}
|
||||
|
||||
/**
|
||||
* Signature help information for a single parameter
|
||||
* Signature help information for a single parameter
|
||||
*/
|
||||
export interface SignatureHelpParameter {
|
||||
|
||||
@@ -819,18 +819,18 @@ declare namespace ts.server.protocol {
|
||||
displayParts: SymbolDisplayPart[];
|
||||
|
||||
/**
|
||||
* Whether the parameter is optional or not.
|
||||
* Whether the parameter is optional or not.
|
||||
*/
|
||||
isOptional: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a single signature to show in signature help.
|
||||
* Represents a single signature to show in signature help.
|
||||
*/
|
||||
export interface SignatureHelpItem {
|
||||
|
||||
/**
|
||||
* Whether the signature accepts a variable number of arguments.
|
||||
* Whether the signature accepts a variable number of arguments.
|
||||
*/
|
||||
isVariadic: boolean;
|
||||
|
||||
@@ -850,7 +850,7 @@ declare namespace ts.server.protocol {
|
||||
separatorDisplayParts: SymbolDisplayPart[];
|
||||
|
||||
/**
|
||||
* The signature helps items for the parameters.
|
||||
* The signature helps items for the parameters.
|
||||
*/
|
||||
parameters: SignatureHelpParameter[];
|
||||
|
||||
@@ -866,17 +866,17 @@ declare namespace ts.server.protocol {
|
||||
export interface SignatureHelpItems {
|
||||
|
||||
/**
|
||||
* The signature help items.
|
||||
* The signature help items.
|
||||
*/
|
||||
items: SignatureHelpItem[];
|
||||
|
||||
/**
|
||||
* The span for which signature help should appear on a signature
|
||||
* The span for which signature help should appear on a signature
|
||||
*/
|
||||
applicableSpan: TextSpan;
|
||||
|
||||
/**
|
||||
* The item selected in the set of available help items.
|
||||
* The item selected in the set of available help items.
|
||||
*/
|
||||
selectedItemIndex: number;
|
||||
|
||||
@@ -900,7 +900,7 @@ declare namespace ts.server.protocol {
|
||||
|
||||
/**
|
||||
* Signature help request; value of command field is "signatureHelp".
|
||||
* Given a file location (file, line, col), return the signature
|
||||
* Given a file location (file, line, col), return the signature
|
||||
* help.
|
||||
*/
|
||||
export interface SignatureHelpRequest extends FileLocationRequest {
|
||||
@@ -931,8 +931,8 @@ declare namespace ts.server.protocol {
|
||||
}
|
||||
|
||||
/**
|
||||
* GeterrForProjectRequest request; value of command field is
|
||||
* "geterrForProject". It works similarly with 'Geterr', only
|
||||
* GeterrForProjectRequest request; value of command field is
|
||||
* "geterrForProject". It works similarly with 'Geterr', only
|
||||
* it request for every file in this project.
|
||||
*/
|
||||
export interface GeterrForProjectRequest extends Request {
|
||||
@@ -1002,7 +1002,7 @@ declare namespace ts.server.protocol {
|
||||
diagnostics: Diagnostic[];
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Event message for "syntaxDiag" and "semanticDiag" event types.
|
||||
* These events provide syntactic and semantic errors for a file.
|
||||
*/
|
||||
@@ -1010,6 +1010,32 @@ declare namespace ts.server.protocol {
|
||||
body?: DiagnosticEventBody;
|
||||
}
|
||||
|
||||
export interface ConfigFileDiagnosticEventBody {
|
||||
/**
|
||||
* The file which trigged the searching and error-checking of the config file
|
||||
*/
|
||||
triggerFile: string;
|
||||
|
||||
/**
|
||||
* The name of the found config file.
|
||||
*/
|
||||
configFile: string;
|
||||
|
||||
/**
|
||||
* An arry of diagnostic information items for the found config file.
|
||||
*/
|
||||
diagnostics: Diagnostic[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Event message for "configFileDiag" event type.
|
||||
* This event provides errors for a found config file.
|
||||
*/
|
||||
export interface ConfigFileDiagnosticEvent extends Event {
|
||||
body?: ConfigFileDiagnosticEventBody;
|
||||
event: "configFileDiag";
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for reload request.
|
||||
*/
|
||||
@@ -1038,7 +1064,7 @@ declare namespace ts.server.protocol {
|
||||
export interface ReloadResponse extends Response {
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Arguments for saveto request.
|
||||
*/
|
||||
export interface SavetoRequestArgs extends FileRequestArgs {
|
||||
@@ -1114,7 +1140,7 @@ declare namespace ts.server.protocol {
|
||||
*/
|
||||
kindModifiers?: string;
|
||||
|
||||
/**
|
||||
/**
|
||||
* The file in which the symbol is found.
|
||||
*/
|
||||
file: string;
|
||||
@@ -1161,7 +1187,7 @@ declare namespace ts.server.protocol {
|
||||
|
||||
/**
|
||||
* Change request message; value of command field is "change".
|
||||
* Update the server's view of the file named by argument 'file'.
|
||||
* Update the server's view of the file named by argument 'file'.
|
||||
* Server does not currently send a response to a change request.
|
||||
*/
|
||||
export interface ChangeRequest extends FileLocationRequest {
|
||||
|
||||
@@ -266,16 +266,21 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
const sys = <ServerHost>ts.sys;
|
||||
|
||||
// Override sys.write because fs.writeSync is not reliable on Node 4
|
||||
ts.sys.write = (s: string) => writeMessage(s);
|
||||
ts.sys.watchFile = (fileName, callback) => {
|
||||
sys.write = (s: string) => writeMessage(s);
|
||||
sys.watchFile = (fileName, callback) => {
|
||||
const watchedFile = pollingWatchedFileSet.addFile(fileName, callback);
|
||||
return {
|
||||
close: () => pollingWatchedFileSet.removeFile(watchedFile)
|
||||
};
|
||||
};
|
||||
|
||||
const ioSession = new IOSession(ts.sys, logger);
|
||||
sys.setTimeout = setTimeout;
|
||||
sys.clearTimeout = clearTimeout;
|
||||
|
||||
const ioSession = new IOSession(sys, logger);
|
||||
process.on("uncaughtException", function(err: Error) {
|
||||
ioSession.logError(err, "unknown");
|
||||
});
|
||||
|
||||
+30
-2
@@ -68,7 +68,7 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
function formatDiag(fileName: string, project: Project, diag: ts.Diagnostic) {
|
||||
function formatDiag(fileName: string, project: Project, diag: ts.Diagnostic): protocol.Diagnostic {
|
||||
return {
|
||||
start: project.compilerService.host.positionToLineOffset(fileName, diag.start),
|
||||
end: project.compilerService.host.positionToLineOffset(fileName, diag.start + diag.length),
|
||||
@@ -76,6 +76,14 @@ namespace ts.server {
|
||||
};
|
||||
}
|
||||
|
||||
function formatConfigFileDiag(diag: ts.Diagnostic): protocol.Diagnostic {
|
||||
return {
|
||||
start: undefined,
|
||||
end: undefined,
|
||||
text: ts.flattenDiagnosticMessageText(diag.messageText, "\n")
|
||||
};
|
||||
}
|
||||
|
||||
export interface PendingErrorCheck {
|
||||
fileName: string;
|
||||
project: Project;
|
||||
@@ -125,6 +133,8 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
export interface ServerHost extends ts.System {
|
||||
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any;
|
||||
clearTimeout(timeoutId: any): void;
|
||||
}
|
||||
|
||||
export class Session {
|
||||
@@ -178,6 +188,21 @@ namespace ts.server {
|
||||
"\r\n\r\n" + json);
|
||||
}
|
||||
|
||||
public configFileDiagnosticEvent(triggerFile: string, configFile: string, diagnostics: ts.Diagnostic[]) {
|
||||
const bakedDiags = ts.map(diagnostics, formatConfigFileDiag);
|
||||
const ev: protocol.ConfigFileDiagnosticEvent = {
|
||||
seq: 0,
|
||||
type: "event",
|
||||
event: "configFileDiag",
|
||||
body: {
|
||||
triggerFile,
|
||||
configFile,
|
||||
diagnostics: bakedDiags
|
||||
}
|
||||
};
|
||||
this.send(ev);
|
||||
}
|
||||
|
||||
public event(info: any, eventName: string) {
|
||||
const ev: protocol.Event = {
|
||||
seq: 0,
|
||||
@@ -561,7 +586,10 @@ namespace ts.server {
|
||||
*/
|
||||
private openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind) {
|
||||
const file = ts.normalizePath(fileName);
|
||||
this.projectService.openClientFile(file, fileContent, scriptKind);
|
||||
const { configFileName, configFileErrors } = this.projectService.openClientFile(file, fileContent, scriptKind);
|
||||
if (configFileErrors) {
|
||||
this.configFileDiagnosticEvent(fileName, configFileName, configFileErrors);
|
||||
}
|
||||
}
|
||||
|
||||
private getQuickInfo(line: number, offset: number, fileName: string): protocol.QuickInfoResponseBody {
|
||||
|
||||
+11
-11
@@ -24,7 +24,7 @@ namespace ts.BreakpointResolver {
|
||||
// token on same line if trailing trivia (comments or white spaces on same line) part of the last token on that line
|
||||
tokenAtLocation = findPrecedingToken(tokenAtLocation.pos, sourceFile);
|
||||
|
||||
// Its a blank line
|
||||
// It's a blank line
|
||||
if (!tokenAtLocation || sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -312,7 +312,7 @@ namespace ts.BreakpointResolver {
|
||||
|
||||
case SyntaxKind.BinaryExpression:
|
||||
if ((<BinaryExpression>node.parent).operatorToken.kind === SyntaxKind.CommaToken) {
|
||||
// if this is comma expression, the breakpoint is possible in this expression
|
||||
// If this is a comma expression, the breakpoint is possible in this expression
|
||||
return textSpan(node);
|
||||
}
|
||||
break;
|
||||
@@ -387,7 +387,7 @@ namespace ts.BreakpointResolver {
|
||||
return spanInNode(variableDeclaration.parent.parent);
|
||||
}
|
||||
|
||||
// If this is a destructuring pattern set breakpoint in binding pattern
|
||||
// If this is a destructuring pattern, set breakpoint in binding pattern
|
||||
if (isBindingPattern(variableDeclaration.name)) {
|
||||
return spanInBindingPattern(<BindingPattern>variableDeclaration.name);
|
||||
}
|
||||
@@ -402,9 +402,9 @@ namespace ts.BreakpointResolver {
|
||||
|
||||
let declarations = variableDeclaration.parent.declarations;
|
||||
if (declarations && declarations[0] !== variableDeclaration) {
|
||||
// If we cant set breakpoint on this declaration, set it on previous one
|
||||
// If we cannot set breakpoint on this declaration, set it on previous one
|
||||
// Because the variable declaration may be binding pattern and
|
||||
// we would like to set breakpoint in last binding element if thats the case,
|
||||
// we would like to set breakpoint in last binding element if that's the case,
|
||||
// use preceding token instead
|
||||
return spanInNode(findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent));
|
||||
}
|
||||
@@ -418,7 +418,7 @@ namespace ts.BreakpointResolver {
|
||||
|
||||
function spanInParameterDeclaration(parameter: ParameterDeclaration): TextSpan {
|
||||
if (isBindingPattern(parameter.name)) {
|
||||
// set breakpoint in binding pattern
|
||||
// Set breakpoint in binding pattern
|
||||
return spanInBindingPattern(<BindingPattern>parameter.name);
|
||||
}
|
||||
else if (canHaveSpanInParameterDeclaration(parameter)) {
|
||||
@@ -492,7 +492,7 @@ namespace ts.BreakpointResolver {
|
||||
|
||||
function spanInInitializerOfForLike(forLikeStatement: ForStatement | ForOfStatement | ForInStatement): TextSpan {
|
||||
if (forLikeStatement.initializer.kind === SyntaxKind.VariableDeclarationList) {
|
||||
// declaration list, set breakpoint in first declaration
|
||||
// Declaration list - set breakpoint in first declaration
|
||||
let variableDeclarationList = <VariableDeclarationList>forLikeStatement.initializer;
|
||||
if (variableDeclarationList.declarations.length > 0) {
|
||||
return spanInNode(variableDeclarationList.declarations[0]);
|
||||
@@ -578,7 +578,7 @@ namespace ts.BreakpointResolver {
|
||||
function spanInCloseBraceToken(node: Node): TextSpan {
|
||||
switch (node.parent.kind) {
|
||||
case SyntaxKind.ModuleBlock:
|
||||
// If this is not instantiated module block no bp span
|
||||
// If this is not an instantiated module block, no bp span
|
||||
if (getModuleInstanceState(node.parent.parent) !== ModuleInstanceState.Instantiated) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -593,7 +593,7 @@ namespace ts.BreakpointResolver {
|
||||
// Span on close brace token
|
||||
return textSpan(node);
|
||||
}
|
||||
// fall through.
|
||||
// fall through
|
||||
|
||||
case SyntaxKind.CatchClause:
|
||||
return spanInNode(lastOrUndefined((<Block>node.parent).statements));
|
||||
@@ -714,7 +714,7 @@ namespace ts.BreakpointResolver {
|
||||
|
||||
function spanInOfKeyword(node: Node): TextSpan {
|
||||
if (node.parent.kind === SyntaxKind.ForOfStatement) {
|
||||
// set using next token
|
||||
// Set using next token
|
||||
return spanInNextNode(node);
|
||||
}
|
||||
|
||||
@@ -723,4 +723,4 @@ namespace ts.BreakpointResolver {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,13 +20,13 @@ namespace ts.formatting {
|
||||
Unknown = -1
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Indentation for the scope that can be dynamically recomputed.
|
||||
* i.e
|
||||
* i.e
|
||||
* while(true)
|
||||
* { let x;
|
||||
* }
|
||||
* Normally indentation is applied only to the first token in line so at glance 'var' should not be touched.
|
||||
* Normally indentation is applied only to the first token in line so at glance 'var' should not be touched.
|
||||
* However if some format rule adds new line between '}' and 'var' 'var' will become
|
||||
* the first token in line so it should be indented
|
||||
*/
|
||||
@@ -48,15 +48,15 @@ namespace ts.formatting {
|
||||
* foo(bar({
|
||||
* $
|
||||
* }))
|
||||
* Both 'foo', 'bar' introduce new indentation with delta = 4, but total indentation in $ is not 8.
|
||||
* Both 'foo', 'bar' introduce new indentation with delta = 4, but total indentation in $ is not 8.
|
||||
* foo: { indentation: 0, delta: 4 }
|
||||
* bar: { indentation: foo.indentation + foo.delta = 4, delta: 4} however 'foo' and 'bar' are on the same line
|
||||
* so bar inherits indentation from foo and bar.delta will be 4
|
||||
*
|
||||
*
|
||||
*/
|
||||
getDelta(child: TextRangeWithKind): number;
|
||||
/**
|
||||
* Formatter calls this function when rule adds or deletes new lines from the text
|
||||
* Formatter calls this function when rule adds or deletes new lines from the text
|
||||
* so indentation scope can adjust values of indentation and delta.
|
||||
*/
|
||||
recomputeIndentation(lineAddedByFormatting: boolean): void;
|
||||
@@ -130,9 +130,9 @@ namespace ts.formatting {
|
||||
function findOutermostParent(position: number, expectedTokenKind: SyntaxKind, sourceFile: SourceFile): Node {
|
||||
let precedingToken = findPrecedingToken(position, sourceFile);
|
||||
|
||||
// when it is claimed that trigger character was typed at given position
|
||||
// when it is claimed that trigger character was typed at given position
|
||||
// we verify that there is a token with a matching kind whose end is equal to position (because the character was just typed).
|
||||
// If this condition is not hold - then trigger character was typed in some other context,
|
||||
// If this condition is not hold - then trigger character was typed in some other context,
|
||||
// i.e.in comment and thus should not trigger autoformatting
|
||||
if (!precedingToken ||
|
||||
precedingToken.kind !== expectedTokenKind ||
|
||||
@@ -142,12 +142,12 @@ namespace ts.formatting {
|
||||
|
||||
// walk up and search for the parent node that ends at the same position with precedingToken.
|
||||
// for cases like this
|
||||
//
|
||||
//
|
||||
// let x = 1;
|
||||
// while (true) {
|
||||
// }
|
||||
// }
|
||||
// after typing close curly in while statement we want to reformat just the while statement.
|
||||
// However if we just walk upwards searching for the parent that has the same end value -
|
||||
// However if we just walk upwards searching for the parent that has the same end value -
|
||||
// we'll end up with the whole source file. isListElement allows to stop on the list element level
|
||||
let current = precedingToken;
|
||||
while (current &&
|
||||
@@ -223,7 +223,7 @@ namespace ts.formatting {
|
||||
// 'index' tracks the index of the most recent error that was checked.
|
||||
while (true) {
|
||||
if (index >= sorted.length) {
|
||||
// all errors in the range were already checked -> no error in specified range
|
||||
// all errors in the range were already checked -> no error in specified range
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ namespace ts.formatting {
|
||||
|
||||
/**
|
||||
* Start of the original range might fall inside the comment - scanner will not yield appropriate results
|
||||
* This function will look for token that is located before the start of target range
|
||||
* This function will look for token that is located before the start of target range
|
||||
* and return its end as start position for the scanner.
|
||||
*/
|
||||
function getScanStartPosition(enclosingNode: Node, originalRange: TextRange, sourceFile: SourceFile): number {
|
||||
@@ -274,7 +274,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
/*
|
||||
* For cases like
|
||||
* For cases like
|
||||
* if (a ||
|
||||
* b ||$
|
||||
* c) {...}
|
||||
@@ -284,8 +284,8 @@ namespace ts.formatting {
|
||||
* Initial indentation for this node will be 0.
|
||||
* Binary expressions don't introduce new indentation scopes, however it is possible
|
||||
* that some parent node on the same line does - like if statement in this case.
|
||||
* Note that we are considering parents only from the same line with initial node -
|
||||
* if parent is on the different line - its delta was already contributed
|
||||
* Note that we are considering parents only from the same line with initial node -
|
||||
* if parent is on the different line - its delta was already contributed
|
||||
* to the initial indentation.
|
||||
*/
|
||||
function getOwnOrInheritedDelta(n: Node, options: FormatCodeOptions, sourceFile: SourceFile): number {
|
||||
@@ -364,10 +364,10 @@ namespace ts.formatting {
|
||||
// local functions
|
||||
|
||||
/** Tries to compute the indentation for a list element.
|
||||
* If list element is not in range then
|
||||
* function will pick its actual indentation
|
||||
* If list element is not in range then
|
||||
* function will pick its actual indentation
|
||||
* so it can be pushed downstream as inherited indentation.
|
||||
* If list element is in the range - its indentation will be equal
|
||||
* If list element is in the range - its indentation will be equal
|
||||
* to inherited indentation from its predecessors.
|
||||
*/
|
||||
function tryComputeIndentationForListItem(startPos: number,
|
||||
@@ -378,7 +378,7 @@ namespace ts.formatting {
|
||||
|
||||
if (rangeOverlapsWithStartEnd(range, startPos, endPos) ||
|
||||
rangeContainsStartEnd(range, startPos, endPos) /* Not to miss zero-range nodes e.g. JsxText */) {
|
||||
|
||||
|
||||
if (inheritedIndentation !== Constants.Unknown) {
|
||||
return inheritedIndentation;
|
||||
}
|
||||
@@ -529,12 +529,12 @@ namespace ts.formatting {
|
||||
// a useful observations when tracking context node
|
||||
// /
|
||||
// [a]
|
||||
// / | \
|
||||
// / | \
|
||||
// [b] [c] [d]
|
||||
// node 'a' is a context node for nodes 'b', 'c', 'd'
|
||||
// node 'a' is a context node for nodes 'b', 'c', 'd'
|
||||
// except for the leftmost leaf token in [b] - in this case context node ('e') is located somewhere above 'a'
|
||||
// this rule can be applied recursively to child nodes of 'a'.
|
||||
//
|
||||
//
|
||||
// context node is set to parent node value after processing every child node
|
||||
// context node is set to parent of the token after processing every token
|
||||
|
||||
@@ -567,7 +567,8 @@ namespace ts.formatting {
|
||||
parentDynamicIndentation: DynamicIndentation,
|
||||
parentStartLine: number,
|
||||
undecoratedParentStartLine: number,
|
||||
isListItem: boolean): number {
|
||||
isListItem: boolean,
|
||||
isFirstListItem?: boolean): number {
|
||||
|
||||
let childStartPos = child.getStart(sourceFile);
|
||||
|
||||
@@ -626,6 +627,10 @@ namespace ts.formatting {
|
||||
|
||||
childContextNode = node;
|
||||
|
||||
if (isFirstListItem && parent.kind === SyntaxKind.ArrayLiteralExpression && inheritedIndentation === Constants.Unknown) {
|
||||
inheritedIndentation = childIndentation.indentation;
|
||||
}
|
||||
|
||||
return inheritedIndentation;
|
||||
}
|
||||
|
||||
@@ -665,8 +670,9 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
let inheritedIndentation = Constants.Unknown;
|
||||
for (let child of nodes) {
|
||||
inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true)
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
const child = nodes[i];
|
||||
inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true, /*isFirstListItem*/ i === 0);
|
||||
}
|
||||
|
||||
if (listEndToken !== SyntaxKind.Unknown) {
|
||||
@@ -674,7 +680,7 @@ namespace ts.formatting {
|
||||
let tokenInfo = formattingScanner.readTokenInfo(parent);
|
||||
// consume the list end token only if it is still belong to the parent
|
||||
// there might be the case when current token matches end token but does not considered as one
|
||||
// function (x: function) <--
|
||||
// function (x: function) <--
|
||||
// without this check close paren will be interpreted as list end token for function expression which is wrong
|
||||
if (tokenInfo.token.kind === listEndToken && rangeContainsRange(parent, tokenInfo.token)) {
|
||||
// consume list end token
|
||||
@@ -733,7 +739,7 @@ namespace ts.formatting {
|
||||
let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container);
|
||||
|
||||
for (let triviaItem of currentTokenInfo.leadingTrivia) {
|
||||
const triviaInRange = rangeContainsRange(originalRange, triviaItem);
|
||||
const triviaInRange = rangeContainsRange(originalRange, triviaItem);
|
||||
switch (triviaItem.kind) {
|
||||
case SyntaxKind.MultiLineCommentTrivia:
|
||||
if (triviaInRange) {
|
||||
@@ -826,7 +832,7 @@ namespace ts.formatting {
|
||||
|
||||
if (rule.Operation.Action & (RuleAction.Space | RuleAction.Delete) && currentStartLine !== previousStartLine) {
|
||||
lineAdded = false;
|
||||
// Handle the case where the next line is moved to be the end of this line.
|
||||
// Handle the case where the next line is moved to be the end of this line.
|
||||
// In this case we don't indent the next line in the next pass.
|
||||
if (currentParent.getStart(sourceFile) === currentItem.pos) {
|
||||
dynamicIndentation.recomputeIndentation(/*lineAdded*/ false);
|
||||
@@ -834,7 +840,7 @@ namespace ts.formatting {
|
||||
}
|
||||
else if (rule.Operation.Action & RuleAction.NewLine && currentStartLine === previousStartLine) {
|
||||
lineAdded = true;
|
||||
// Handle the case where token2 is moved to the new line.
|
||||
// Handle the case where token2 is moved to the new line.
|
||||
// In this case we indent token2 in the next pass but we set
|
||||
// sameLineIndent flag to notify the indenter that the indentation is within the line.
|
||||
if (currentParent.getStart(sourceFile) === currentItem.pos) {
|
||||
@@ -866,13 +872,17 @@ namespace ts.formatting {
|
||||
}
|
||||
else {
|
||||
let tokenStart = sourceFile.getLineAndCharacterOfPosition(pos);
|
||||
if (indentation !== tokenStart.character) {
|
||||
let startLinePosition = getStartPositionOfLine(tokenStart.line, sourceFile);
|
||||
let startLinePosition = getStartPositionOfLine(tokenStart.line, sourceFile);
|
||||
if (indentation !== tokenStart.character || indentationIsDifferent(indentationString, startLinePosition)) {
|
||||
recordReplace(startLinePosition, tokenStart.character, indentationString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function indentationIsDifferent(indentationString: string, startLinePosition: number): boolean {
|
||||
return indentationString !== sourceFile.text.substr(startLinePosition , indentationString.length);
|
||||
}
|
||||
|
||||
function indentMultilineComment(commentRange: TextRange, indentation: number, firstLineIsIndented: boolean) {
|
||||
// split comment in lines
|
||||
let startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line;
|
||||
@@ -1152,4 +1162,4 @@ namespace ts.formatting {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
namespace ts.NavigateTo {
|
||||
type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration };
|
||||
|
||||
export function getNavigateToItems(program: Program, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number): NavigateToItem[] {
|
||||
export function getNavigateToItems(program: Program, checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number): NavigateToItem[] {
|
||||
const patternMatcher = createPatternMatcher(searchValue);
|
||||
let rawItems: RawNavigateToItem[] = [];
|
||||
|
||||
@@ -49,6 +49,19 @@ namespace ts.NavigateTo {
|
||||
}
|
||||
});
|
||||
|
||||
// Remove imports when the imported declaration is already in the list and has the same name.
|
||||
rawItems = filter(rawItems, item => {
|
||||
const decl = item.declaration;
|
||||
if (decl.kind === SyntaxKind.ImportClause || decl.kind === SyntaxKind.ImportSpecifier || decl.kind === SyntaxKind.ImportEqualsDeclaration) {
|
||||
const importer = checker.getSymbolAtLocation(decl.name);
|
||||
const imported = checker.getAliasedSymbol(importer);
|
||||
return importer.name !== imported.name;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
rawItems.sort(compareNavigateToItems);
|
||||
if (maxResultCount !== undefined) {
|
||||
rawItems = rawItems.slice(0, maxResultCount);
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace ts.NavigationBar {
|
||||
}
|
||||
|
||||
function getChildNodes(nodes: Node[]): Node[] {
|
||||
let childNodes: Node[] = [];
|
||||
const childNodes: Node[] = [];
|
||||
|
||||
function visit(node: Node) {
|
||||
switch (node.kind) {
|
||||
@@ -109,7 +109,7 @@ namespace ts.NavigationBar {
|
||||
}
|
||||
}
|
||||
|
||||
//for (let i = 0, n = nodes.length; i < n; i++) {
|
||||
// for (let i = 0, n = nodes.length; i < n; i++) {
|
||||
// let node = nodes[i];
|
||||
|
||||
// if (node.kind === SyntaxKind.ClassDeclaration ||
|
||||
@@ -123,13 +123,13 @@ namespace ts.NavigationBar {
|
||||
// else if (node.kind === SyntaxKind.VariableStatement) {
|
||||
// childNodes.push.apply(childNodes, (<VariableStatement>node).declarations);
|
||||
// }
|
||||
//}
|
||||
// }
|
||||
forEach(nodes, visit);
|
||||
return sortNodes(childNodes);
|
||||
}
|
||||
|
||||
function getTopLevelNodes(node: SourceFile): Node[] {
|
||||
let topLevelNodes: Node[] = [];
|
||||
const topLevelNodes: Node[] = [];
|
||||
topLevelNodes.push(node);
|
||||
|
||||
addTopLevelNodes(node.statements, topLevelNodes);
|
||||
@@ -157,7 +157,7 @@ namespace ts.NavigationBar {
|
||||
function addTopLevelNodes(nodes: Node[], topLevelNodes: Node[]): void {
|
||||
nodes = sortNodes(nodes);
|
||||
|
||||
for (let node of nodes) {
|
||||
for (const node of nodes) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
topLevelNodes.push(node);
|
||||
@@ -176,6 +176,7 @@ namespace ts.NavigationBar {
|
||||
break;
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
topLevelNodes.push(node);
|
||||
break;
|
||||
|
||||
@@ -197,7 +198,7 @@ namespace ts.NavigationBar {
|
||||
}
|
||||
|
||||
function hasNamedFunctionDeclarations(nodes: NodeArray<Statement>): boolean {
|
||||
for (let s of nodes) {
|
||||
for (const s of nodes) {
|
||||
if (s.kind === SyntaxKind.FunctionDeclaration && !isEmpty((<FunctionDeclaration>s).name.text)) {
|
||||
return true;
|
||||
}
|
||||
@@ -237,17 +238,17 @@ namespace ts.NavigationBar {
|
||||
}
|
||||
|
||||
function getItemsWorker(nodes: Node[], createItem: (n: Node) => ts.NavigationBarItem): ts.NavigationBarItem[] {
|
||||
let items: ts.NavigationBarItem[] = [];
|
||||
const items: ts.NavigationBarItem[] = [];
|
||||
|
||||
let keyToItem: Map<NavigationBarItem> = {};
|
||||
const keyToItem: Map<NavigationBarItem> = {};
|
||||
|
||||
for (let child of nodes) {
|
||||
let item = createItem(child);
|
||||
for (const child of nodes) {
|
||||
const item = createItem(child);
|
||||
if (item !== undefined) {
|
||||
if (item.text.length > 0) {
|
||||
let key = item.text + "-" + item.kind + "-" + item.indent;
|
||||
const key = item.text + "-" + item.kind + "-" + item.indent;
|
||||
|
||||
let itemWithSameName = keyToItem[key];
|
||||
const itemWithSameName = keyToItem[key];
|
||||
if (itemWithSameName) {
|
||||
// We had an item with the same name. Merge these items together.
|
||||
merge(itemWithSameName, item);
|
||||
@@ -274,8 +275,8 @@ namespace ts.NavigationBar {
|
||||
|
||||
// Next, recursively merge or add any children in the source as appropriate.
|
||||
outer:
|
||||
for (let sourceChild of source.childItems) {
|
||||
for (let targetChild of target.childItems) {
|
||||
for (const sourceChild of source.childItems) {
|
||||
for (const targetChild of target.childItems) {
|
||||
if (targetChild.text === sourceChild.text && targetChild.kind === sourceChild.kind) {
|
||||
// Found a match. merge them.
|
||||
merge(targetChild, sourceChild);
|
||||
@@ -313,6 +314,9 @@ namespace ts.NavigationBar {
|
||||
case SyntaxKind.IndexSignature:
|
||||
return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement);
|
||||
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return createItem(node, getTextOfNode((<EnumDeclaration>node).name), ts.ScriptElementKind.enumElement);
|
||||
|
||||
case SyntaxKind.EnumMember:
|
||||
return createItem(node, getTextOfNode((<EnumMember>node).name), ts.ScriptElementKind.memberVariableElement);
|
||||
|
||||
@@ -382,7 +386,7 @@ namespace ts.NavigationBar {
|
||||
return !text || text.trim() === "";
|
||||
}
|
||||
|
||||
function getNavigationBarItem(text: string, kind: string, kindModifiers: string, spans: TextSpan[], childItems: NavigationBarItem[] = [], indent: number = 0): NavigationBarItem {
|
||||
function getNavigationBarItem(text: string, kind: string, kindModifiers: string, spans: TextSpan[], childItems: NavigationBarItem[] = [], indent = 0): NavigationBarItem {
|
||||
if (isEmpty(text)) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -422,6 +426,9 @@ namespace ts.NavigationBar {
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
return createFunctionItem(<FunctionDeclaration>node);
|
||||
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
return createTypeAliasItem(<TypeAliasDeclaration>node);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
@@ -433,7 +440,7 @@ namespace ts.NavigationBar {
|
||||
}
|
||||
|
||||
// Otherwise, we need to aggregate each identifier to build up the qualified name.
|
||||
let result: string[] = [];
|
||||
const result: string[] = [];
|
||||
|
||||
result.push(moduleDeclaration.name.text);
|
||||
|
||||
@@ -447,9 +454,9 @@ namespace ts.NavigationBar {
|
||||
}
|
||||
|
||||
function createModuleItem(node: ModuleDeclaration): NavigationBarItem {
|
||||
let moduleName = getModuleName(node);
|
||||
const moduleName = getModuleName(node);
|
||||
|
||||
let childItems = getItemsWorker(getChildNodes((<Block>getInnermostModule(node).body).statements), createChildItem);
|
||||
const childItems = getItemsWorker(getChildNodes((<Block>getInnermostModule(node).body).statements), createChildItem);
|
||||
|
||||
return getNavigationBarItem(moduleName,
|
||||
ts.ScriptElementKind.moduleElement,
|
||||
@@ -461,9 +468,9 @@ namespace ts.NavigationBar {
|
||||
|
||||
function createFunctionItem(node: FunctionDeclaration): ts.NavigationBarItem {
|
||||
if (node.body && node.body.kind === SyntaxKind.Block) {
|
||||
let childItems = getItemsWorker(sortNodes((<Block>node.body).statements), createChildItem);
|
||||
const childItems = getItemsWorker(sortNodes((<Block>node.body).statements), createChildItem);
|
||||
|
||||
return getNavigationBarItem(!node.name ? "default": node.name.text,
|
||||
return getNavigationBarItem(!node.name ? "default" : node.name.text,
|
||||
ts.ScriptElementKind.functionElement,
|
||||
getNodeModifiers(node),
|
||||
[getNodeSpan(node)],
|
||||
@@ -474,9 +481,18 @@ namespace ts.NavigationBar {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function createTypeAliasItem(node: TypeAliasDeclaration): ts.NavigationBarItem {
|
||||
return getNavigationBarItem(node.name.text,
|
||||
ts.ScriptElementKind.typeElement,
|
||||
getNodeModifiers(node),
|
||||
[getNodeSpan(node)],
|
||||
[],
|
||||
getIndent(node));
|
||||
}
|
||||
|
||||
function createMemberFunctionLikeItem(node: MethodDeclaration | ConstructorDeclaration): ts.NavigationBarItem {
|
||||
if (node.body && node.body.kind === SyntaxKind.Block) {
|
||||
let childItems = getItemsWorker(sortNodes((<Block>node.body).statements), createChildItem);
|
||||
const childItems = getItemsWorker(sortNodes((<Block>node.body).statements), createChildItem);
|
||||
let scriptElementKind: string;
|
||||
let memberFunctionName: string;
|
||||
if (node.kind === SyntaxKind.MethodDeclaration) {
|
||||
@@ -500,16 +516,16 @@ namespace ts.NavigationBar {
|
||||
}
|
||||
|
||||
function createSourceFileItem(node: SourceFile): ts.NavigationBarItem {
|
||||
let childItems = getItemsWorker(getChildNodes(node.statements), createChildItem);
|
||||
const childItems = getItemsWorker(getChildNodes(node.statements), createChildItem);
|
||||
|
||||
if (childItems === undefined || childItems.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
hasGlobalNode = true;
|
||||
let rootName = isExternalModule(node)
|
||||
const rootName = isExternalModule(node)
|
||||
? "\"" + escapeString(getBaseFileName(removeFileExtension(normalizePath(node.fileName)))) + "\""
|
||||
: "<global>"
|
||||
: "<global>";
|
||||
|
||||
return getNavigationBarItem(rootName,
|
||||
ts.ScriptElementKind.moduleElement,
|
||||
@@ -522,14 +538,14 @@ namespace ts.NavigationBar {
|
||||
let childItems: NavigationBarItem[];
|
||||
|
||||
if (node.members) {
|
||||
let constructor = <ConstructorDeclaration>forEach(node.members, member => {
|
||||
const constructor = <ConstructorDeclaration>forEach(node.members, member => {
|
||||
return member.kind === SyntaxKind.Constructor && member;
|
||||
});
|
||||
|
||||
// Add the constructor parameters in as children of the class (for property parameters).
|
||||
// Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that
|
||||
// are not properties will be filtered out later by createChildItem.
|
||||
let nodes: Node[] = removeDynamicallyNamedProperties(node);
|
||||
const nodes: Node[] = removeDynamicallyNamedProperties(node);
|
||||
if (constructor) {
|
||||
addRange(nodes, filter(constructor.parameters, p => !isBindingPattern(p.name)));
|
||||
}
|
||||
@@ -537,7 +553,7 @@ namespace ts.NavigationBar {
|
||||
childItems = getItemsWorker(sortNodes(nodes), createChildItem);
|
||||
}
|
||||
|
||||
var nodeName = !node.name ? "default" : node.name.text;
|
||||
const nodeName = !node.name ? "default" : node.name.text;
|
||||
|
||||
return getNavigationBarItem(
|
||||
nodeName,
|
||||
@@ -549,7 +565,7 @@ namespace ts.NavigationBar {
|
||||
}
|
||||
|
||||
function createEnumItem(node: EnumDeclaration): ts.NavigationBarItem {
|
||||
let childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem);
|
||||
const childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem);
|
||||
return getNavigationBarItem(
|
||||
node.name.text,
|
||||
ts.ScriptElementKind.enumElement,
|
||||
@@ -560,7 +576,7 @@ namespace ts.NavigationBar {
|
||||
}
|
||||
|
||||
function createInterfaceItem(node: InterfaceDeclaration): ts.NavigationBarItem {
|
||||
let childItems = getItemsWorker(sortNodes(removeDynamicallyNamedProperties(node)), createChildItem);
|
||||
const childItems = getItemsWorker(sortNodes(removeDynamicallyNamedProperties(node)), createChildItem);
|
||||
return getNavigationBarItem(
|
||||
node.name.text,
|
||||
ts.ScriptElementKind.interfaceElement,
|
||||
@@ -578,7 +594,7 @@ namespace ts.NavigationBar {
|
||||
/**
|
||||
* Like removeComputedProperties, but retains the properties with well known symbol names
|
||||
*/
|
||||
function removeDynamicallyNamedProperties(node: ClassDeclaration | InterfaceDeclaration): Declaration[]{
|
||||
function removeDynamicallyNamedProperties(node: ClassDeclaration | InterfaceDeclaration): Declaration[] {
|
||||
return filter<Declaration>(node.members, member => !hasDynamicName(member));
|
||||
}
|
||||
|
||||
@@ -606,11 +622,11 @@ namespace ts.NavigationBar {
|
||||
const anonClassText = "<class>";
|
||||
let indent = 0;
|
||||
|
||||
let rootName = isExternalModule(sourceFile) ?
|
||||
const rootName = isExternalModule(sourceFile) ?
|
||||
"\"" + escapeString(getBaseFileName(removeFileExtension(normalizePath(sourceFile.fileName)))) + "\""
|
||||
: "<global>";
|
||||
|
||||
let sourceFileItem = getNavBarItem(rootName, ScriptElementKind.moduleElement, [getNodeSpan(sourceFile)]);
|
||||
const sourceFileItem = getNavBarItem(rootName, ScriptElementKind.moduleElement, [getNodeSpan(sourceFile)]);
|
||||
let topItem = sourceFileItem;
|
||||
|
||||
// Walk the whole file, because we want to also find function expressions - which may be in variable initializer,
|
||||
@@ -643,12 +659,12 @@ namespace ts.NavigationBar {
|
||||
}
|
||||
}
|
||||
|
||||
function createNavBarItem(node: Node) : NavigationBarItem {
|
||||
function createNavBarItem(node: Node): NavigationBarItem {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
// Only add to the navbar if at the top-level of the file
|
||||
// Note: "const" and "let" are also SyntaxKind.VariableDeclarations
|
||||
if(node.parent/*VariableDeclarationList*/.parent/*VariableStatement*/
|
||||
if (node.parent/*VariableDeclarationList*/.parent/*VariableStatement*/
|
||||
.parent/*SourceFile*/.kind !== SyntaxKind.SourceFile) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -711,7 +727,7 @@ namespace ts.NavigationBar {
|
||||
function getNavBarItem(text: string, kind: string, spans: TextSpan[], kindModifiers = ScriptElementKindModifier.none): NavigationBarItem {
|
||||
return {
|
||||
text, kind, kindModifiers, spans, childItems: [], indent, bolded: false, grayed: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getDefineModuleItem(node: Node): NavigationBarItem {
|
||||
@@ -724,7 +740,7 @@ namespace ts.NavigationBar {
|
||||
return undefined;
|
||||
}
|
||||
const callExpr = node.parent as CallExpression;
|
||||
if (callExpr.expression.kind !== SyntaxKind.Identifier || callExpr.expression.getText() !== 'define') {
|
||||
if (callExpr.expression.kind !== SyntaxKind.Identifier || callExpr.expression.getText() !== "define") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
+221
-130
@@ -50,6 +50,7 @@ namespace ts {
|
||||
getStringIndexType(): Type;
|
||||
getNumberIndexType(): Type;
|
||||
getBaseTypes(): ObjectType[];
|
||||
getNonNullableType(): Type;
|
||||
}
|
||||
|
||||
export interface Signature {
|
||||
@@ -757,6 +758,9 @@ namespace ts {
|
||||
? this.checker.getBaseTypes(<InterfaceType><Type>this)
|
||||
: undefined;
|
||||
}
|
||||
getNonNullableType(): Type {
|
||||
return this.checker.getNonNullableType(this);
|
||||
}
|
||||
}
|
||||
|
||||
class SignatureObject implements Signature {
|
||||
@@ -926,6 +930,7 @@ namespace ts {
|
||||
function visit(node: Node): void {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
const functionDeclaration = <FunctionLikeDeclaration>node;
|
||||
@@ -952,6 +957,7 @@ namespace ts {
|
||||
break;
|
||||
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
@@ -966,34 +972,25 @@ namespace ts {
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
addDeclaration(<Declaration>node);
|
||||
// fall through
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.VariableStatement:
|
||||
case SyntaxKind.VariableDeclarationList:
|
||||
case SyntaxKind.ObjectBindingPattern:
|
||||
case SyntaxKind.ArrayBindingPattern:
|
||||
case SyntaxKind.ModuleBlock:
|
||||
forEachChild(node, visit);
|
||||
break;
|
||||
|
||||
case SyntaxKind.Block:
|
||||
if (isFunctionBlock(node)) {
|
||||
forEachChild(node, visit);
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.Parameter:
|
||||
// Only consider properties defined as constructor parameters
|
||||
if (!(node.flags & NodeFlags.AccessibilityModifier)) {
|
||||
// Only consider parameter properties
|
||||
if (!(node.flags & NodeFlags.ParameterPropertyModifier)) {
|
||||
break;
|
||||
}
|
||||
// fall through
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.BindingElement:
|
||||
if (isBindingPattern((<VariableDeclaration>node).name)) {
|
||||
forEachChild((<VariableDeclaration>node).name, visit);
|
||||
case SyntaxKind.BindingElement: {
|
||||
const decl = <VariableDeclaration> node;
|
||||
if (isBindingPattern(decl.name)) {
|
||||
forEachChild(decl.name, visit);
|
||||
break;
|
||||
}
|
||||
if (decl.initializer)
|
||||
visit(decl.initializer);
|
||||
}
|
||||
case SyntaxKind.EnumMember:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
@@ -1030,6 +1027,9 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
forEachChild(node, visit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1503,6 +1503,15 @@ namespace ts {
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
|
||||
acquireDocumentWithKey(
|
||||
fileName: string,
|
||||
path: Path,
|
||||
compilationSettings: CompilerOptions,
|
||||
key: DocumentRegistryBucketKey,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile
|
||||
@@ -1522,6 +1531,16 @@ namespace ts {
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
|
||||
updateDocumentWithKey(
|
||||
fileName: string,
|
||||
path: Path,
|
||||
compilationSettings: CompilerOptions,
|
||||
key: DocumentRegistryBucketKey,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
|
||||
getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey;
|
||||
/**
|
||||
* Informs the DocumentRegistry that a file is not needed any longer.
|
||||
*
|
||||
@@ -1533,76 +1552,86 @@ namespace ts {
|
||||
*/
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
|
||||
|
||||
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void;
|
||||
|
||||
reportStats(): string;
|
||||
}
|
||||
|
||||
export type DocumentRegistryBucketKey = string & { __bucketKey: any };
|
||||
|
||||
// TODO: move these to enums
|
||||
export namespace ScriptElementKind {
|
||||
export const unknown = "";
|
||||
export const warning = "warning";
|
||||
|
||||
// predefined type (void) or keyword (class)
|
||||
/** predefined type (void) or keyword (class) */
|
||||
export const keyword = "keyword";
|
||||
|
||||
// top level script node
|
||||
/** top level script node */
|
||||
export const scriptElement = "script";
|
||||
|
||||
// module foo {}
|
||||
/** module foo {} */
|
||||
export const moduleElement = "module";
|
||||
|
||||
// class X {}
|
||||
/** class X {} */
|
||||
export const classElement = "class";
|
||||
|
||||
// var x = class X {}
|
||||
/** var x = class X {} */
|
||||
export const localClassElement = "local class";
|
||||
|
||||
// interface Y {}
|
||||
/** interface Y {} */
|
||||
export const interfaceElement = "interface";
|
||||
|
||||
// type T = ...
|
||||
/** type T = ... */
|
||||
export const typeElement = "type";
|
||||
|
||||
// enum E
|
||||
/** enum E */
|
||||
export const enumElement = "enum";
|
||||
|
||||
// Inside module and script only
|
||||
// const v = ..
|
||||
/**
|
||||
* Inside module and script only
|
||||
* const v = ..
|
||||
*/
|
||||
export const variableElement = "var";
|
||||
|
||||
// Inside function
|
||||
/** Inside function */
|
||||
export const localVariableElement = "local var";
|
||||
|
||||
// Inside module and script only
|
||||
// function f() { }
|
||||
/**
|
||||
* Inside module and script only
|
||||
* function f() { }
|
||||
*/
|
||||
export const functionElement = "function";
|
||||
|
||||
// Inside function
|
||||
/** Inside function */
|
||||
export const localFunctionElement = "local function";
|
||||
|
||||
// class X { [public|private]* foo() {} }
|
||||
/** class X { [public|private]* foo() {} } */
|
||||
export const memberFunctionElement = "method";
|
||||
|
||||
// class X { [public|private]* [get|set] foo:number; }
|
||||
/** class X { [public|private]* [get|set] foo:number; } */
|
||||
export const memberGetAccessorElement = "getter";
|
||||
export const memberSetAccessorElement = "setter";
|
||||
|
||||
// class X { [public|private]* foo:number; }
|
||||
// interface Y { foo:number; }
|
||||
/**
|
||||
* class X { [public|private]* foo:number; }
|
||||
* interface Y { foo:number; }
|
||||
*/
|
||||
export const memberVariableElement = "property";
|
||||
|
||||
// class X { constructor() { } }
|
||||
/** class X { constructor() { } } */
|
||||
export const constructorImplementationElement = "constructor";
|
||||
|
||||
// interface Y { ():number; }
|
||||
/** interface Y { ():number; } */
|
||||
export const callSignatureElement = "call";
|
||||
|
||||
// interface Y { []:number; }
|
||||
/** interface Y { []:number; } */
|
||||
export const indexSignatureElement = "index";
|
||||
|
||||
// interface Y { new():Y; }
|
||||
/** interface Y { new():Y; } */
|
||||
export const constructSignatureElement = "construct";
|
||||
|
||||
// function foo(*Y*: string)
|
||||
/** function foo(*Y*: string) */
|
||||
export const parameterElement = "parameter";
|
||||
|
||||
export const typeParameterElement = "type parameter";
|
||||
@@ -1805,11 +1834,13 @@ namespace ts {
|
||||
|
||||
public getOrCreateEntry(fileName: string): HostFileInformation {
|
||||
const path = toPath(fileName, this.currentDirectory, this.getCanonicalFileName);
|
||||
if (this.contains(path)) {
|
||||
return this.getEntry(path);
|
||||
}
|
||||
return this.getOrCreateEntryByPath(fileName, path);
|
||||
}
|
||||
|
||||
return this.createEntry(fileName, path);
|
||||
public getOrCreateEntryByPath(fileName: string, path: Path): HostFileInformation {
|
||||
return this.contains(path)
|
||||
? this.getEntry(path)
|
||||
: this.createEntry(fileName, path);
|
||||
}
|
||||
|
||||
public getRootFileNames(): string[] {
|
||||
@@ -1943,7 +1974,7 @@ namespace ts {
|
||||
|
||||
// Create a compilerHost object to allow the compiler to read and write files
|
||||
const compilerHost: CompilerHost = {
|
||||
getSourceFile: (fileName, target) => fileName === normalizeSlashes(inputFileName) ? sourceFile : undefined,
|
||||
getSourceFile: (fileName, target) => fileName === normalizePath(inputFileName) ? sourceFile : undefined,
|
||||
writeFile: (name, text, writeByteOrderMark) => {
|
||||
if (fileExtensionIs(name, ".map")) {
|
||||
Debug.assert(sourceMapText === undefined, `Unexpected multiple source map outputs for the file '${name}'`);
|
||||
@@ -2063,12 +2094,11 @@ namespace ts {
|
||||
const buckets: Map<FileMap<DocumentRegistryEntry>> = {};
|
||||
const getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames);
|
||||
|
||||
function getKeyFromCompilationSettings(settings: CompilerOptions): string {
|
||||
return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + +"|" + settings.allowJs;
|
||||
function getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey {
|
||||
return <DocumentRegistryBucketKey>`_${settings.target}|${settings.module}|${settings.noResolve}|${settings.jsx}|${settings.allowJs}|${settings.baseUrl}|${settings.typesRoot}|${settings.typesSearchPaths}|${JSON.stringify(settings.rootDirs)}|${JSON.stringify(settings.paths)}`;
|
||||
}
|
||||
|
||||
function getBucketForCompilationSettings(settings: CompilerOptions, createIfMissing: boolean): FileMap<DocumentRegistryEntry> {
|
||||
const key = getKeyFromCompilationSettings(settings);
|
||||
function getBucketForCompilationSettings(key: DocumentRegistryBucketKey, createIfMissing: boolean): FileMap<DocumentRegistryEntry> {
|
||||
let bucket = lookUp(buckets, key);
|
||||
if (!bucket && createIfMissing) {
|
||||
buckets[key] = bucket = createFileMap<DocumentRegistryEntry>();
|
||||
@@ -2097,23 +2127,36 @@ namespace ts {
|
||||
}
|
||||
|
||||
function acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring*/ true, scriptKind);
|
||||
const path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
const key = getKeyForCompilationSettings(compilationSettings);
|
||||
return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
|
||||
}
|
||||
|
||||
function acquireDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind);
|
||||
}
|
||||
|
||||
function updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
|
||||
const path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
const key = getKeyForCompilationSettings(compilationSettings);
|
||||
return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
|
||||
}
|
||||
|
||||
function updateDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
|
||||
}
|
||||
|
||||
function acquireOrUpdateDocument(
|
||||
fileName: string,
|
||||
path: Path,
|
||||
compilationSettings: CompilerOptions,
|
||||
key: DocumentRegistryBucketKey,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
acquiring: boolean,
|
||||
scriptKind?: ScriptKind): SourceFile {
|
||||
|
||||
const bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true);
|
||||
const path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
const bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ true);
|
||||
let entry = bucket.get(path);
|
||||
if (!entry) {
|
||||
Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?");
|
||||
@@ -2151,10 +2194,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
function releaseDocument(fileName: string, compilationSettings: CompilerOptions): void {
|
||||
const bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/false);
|
||||
Debug.assert(bucket !== undefined);
|
||||
|
||||
const path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
const key = getKeyForCompilationSettings(compilationSettings);
|
||||
return releaseDocumentWithKey(path, key);
|
||||
}
|
||||
|
||||
function releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void {
|
||||
const bucket = getBucketForCompilationSettings(key, /*createIfMissing*/false);
|
||||
Debug.assert(bucket !== undefined);
|
||||
|
||||
const entry = bucket.get(path);
|
||||
entry.languageServiceRefCount--;
|
||||
@@ -2167,9 +2214,13 @@ namespace ts {
|
||||
|
||||
return {
|
||||
acquireDocument,
|
||||
acquireDocumentWithKey,
|
||||
updateDocument,
|
||||
updateDocumentWithKey,
|
||||
releaseDocument,
|
||||
reportStats
|
||||
releaseDocumentWithKey,
|
||||
reportStats,
|
||||
getKeyForCompilationSettings
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2603,10 +2654,33 @@ namespace ts {
|
||||
isFunctionLike(node.parent) && (<FunctionLikeDeclaration>node.parent).name === node;
|
||||
}
|
||||
|
||||
/** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */
|
||||
function isNameOfPropertyAssignment(node: Node): boolean {
|
||||
return (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) &&
|
||||
(node.parent.kind === SyntaxKind.PropertyAssignment || node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) && (<PropertyDeclaration>node.parent).name === node;
|
||||
function isObjectLiteralPropertyDeclaration(node: Node): node is ObjectLiteralElement {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the containing object literal property declaration given a possible name node, e.g. "a" in x = { "a": 1 }
|
||||
*/
|
||||
function getContainingObjectLiteralElement(node: Node): ObjectLiteralElement {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
if (node.parent.kind === SyntaxKind.ComputedPropertyName) {
|
||||
return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined;
|
||||
}
|
||||
// intential fall through
|
||||
case SyntaxKind.Identifier:
|
||||
return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function isLiteralNameOfPropertyDeclarationOrIndexAccess(node: Node): boolean {
|
||||
@@ -2624,6 +2698,8 @@ namespace ts {
|
||||
return (<Declaration>node.parent).name === node;
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
return (<ElementAccessExpression>node.parent).argumentExpression === node;
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2722,7 +2798,9 @@ namespace ts {
|
||||
/* @internal */ export function getNodeKind(node: Node): string {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ModuleDeclaration: return ScriptElementKind.moduleElement;
|
||||
case SyntaxKind.ClassDeclaration: return ScriptElementKind.classElement;
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.ClassExpression:
|
||||
return ScriptElementKind.classElement;
|
||||
case SyntaxKind.InterfaceDeclaration: return ScriptElementKind.interfaceElement;
|
||||
case SyntaxKind.TypeAliasDeclaration: return ScriptElementKind.typeElement;
|
||||
case SyntaxKind.EnumDeclaration: return ScriptElementKind.enumElement;
|
||||
@@ -2732,7 +2810,9 @@ namespace ts {
|
||||
: isLet(node)
|
||||
? ScriptElementKind.letElement
|
||||
: ScriptElementKind.variableElement;
|
||||
case SyntaxKind.FunctionDeclaration: return ScriptElementKind.functionElement;
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
return ScriptElementKind.functionElement;
|
||||
case SyntaxKind.GetAccessor: return ScriptElementKind.memberGetAccessorElement;
|
||||
case SyntaxKind.SetAccessor: return ScriptElementKind.memberSetAccessorElement;
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
@@ -2747,7 +2827,7 @@ namespace ts {
|
||||
case SyntaxKind.Constructor: return ScriptElementKind.constructorImplementationElement;
|
||||
case SyntaxKind.TypeParameter: return ScriptElementKind.typeParameterElement;
|
||||
case SyntaxKind.EnumMember: return ScriptElementKind.variableElement;
|
||||
case SyntaxKind.Parameter: return (node.flags & NodeFlags.AccessibilityModifier) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement;
|
||||
case SyntaxKind.Parameter: return (node.flags & NodeFlags.ParameterPropertyModifier) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement;
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.ImportClause:
|
||||
@@ -2855,6 +2935,7 @@ namespace ts {
|
||||
// Now create a new compiler
|
||||
const compilerHost: CompilerHost = {
|
||||
getSourceFile: getOrCreateSourceFile,
|
||||
getSourceFileByPath: getOrCreateSourceFileByPath,
|
||||
getCancellationToken: () => cancellationToken,
|
||||
getCanonicalFileName,
|
||||
useCaseSensitiveFileNames: () => useCaseSensitivefileNames,
|
||||
@@ -2890,15 +2971,17 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
const documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
|
||||
const newProgram = createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program);
|
||||
|
||||
// Release any files we have acquired in the old program but are
|
||||
// not part of the new program.
|
||||
if (program) {
|
||||
const oldSourceFiles = program.getSourceFiles();
|
||||
const oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldSettings);
|
||||
for (const oldSourceFile of oldSourceFiles) {
|
||||
if (!newProgram.getSourceFile(oldSourceFile.fileName) || changesInCompilationSettingsAffectSyntax) {
|
||||
documentRegistry.releaseDocument(oldSourceFile.fileName, oldSettings);
|
||||
documentRegistry.releaseDocumentWithKey(oldSourceFile.path, oldSettingsKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2915,11 +2998,15 @@ namespace ts {
|
||||
return;
|
||||
|
||||
function getOrCreateSourceFile(fileName: string): SourceFile {
|
||||
return getOrCreateSourceFileByPath(fileName, toPath(fileName, currentDirectory, getCanonicalFileName));
|
||||
}
|
||||
|
||||
function getOrCreateSourceFileByPath(fileName: string, path: Path): SourceFile {
|
||||
Debug.assert(hostCache !== undefined);
|
||||
// The program is asking for this file, check first if the host can locate it.
|
||||
// If the host can not locate the file, then it does not exist. return undefined
|
||||
// to the program to allow reporting of errors for missing files.
|
||||
const hostFileInformation = hostCache.getOrCreateEntry(fileName);
|
||||
const hostFileInformation = hostCache.getOrCreateEntryByPath(fileName, path);
|
||||
if (!hostFileInformation) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -2929,7 +3016,7 @@ namespace ts {
|
||||
// can not be reused. we have to dump all syntax trees and create new ones.
|
||||
if (!changesInCompilationSettingsAffectSyntax) {
|
||||
// Check if the old program had this file already
|
||||
const oldSourceFile = program && program.getSourceFile(fileName);
|
||||
const oldSourceFile = program && program.getSourceFileByPath(path);
|
||||
if (oldSourceFile) {
|
||||
// We already had a source file for this file name. Go to the registry to
|
||||
// ensure that we get the right up to date version of it. We need this to
|
||||
@@ -2956,16 +3043,16 @@ namespace ts {
|
||||
// We do not support the scenario where a host can modify a registered
|
||||
// file's script kind, i.e. in one project some file is treated as ".ts"
|
||||
// and in another as ".js"
|
||||
Debug.assert(hostFileInformation.scriptKind === oldSourceFile.scriptKind, "Registered script kind (" + oldSourceFile.scriptKind + ") should match new script kind (" + hostFileInformation.scriptKind + ") for file: " + fileName);
|
||||
Debug.assert(hostFileInformation.scriptKind === oldSourceFile.scriptKind, "Registered script kind (" + oldSourceFile.scriptKind + ") should match new script kind (" + hostFileInformation.scriptKind + ") for file: " + path);
|
||||
|
||||
return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
|
||||
return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
|
||||
}
|
||||
|
||||
// We didn't already have the file. Fall through and acquire it from the registry.
|
||||
}
|
||||
|
||||
// Could not find this file in the old program, create a new SourceFile for it.
|
||||
return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
|
||||
return documentRegistry.acquireDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
|
||||
}
|
||||
|
||||
function sourceFileUpToDate(sourceFile: SourceFile): boolean {
|
||||
@@ -4294,7 +4381,7 @@ namespace ts {
|
||||
displayParts.push(keywordPart(SyntaxKind.NewKeyword));
|
||||
displayParts.push(spacePart());
|
||||
}
|
||||
if (!(type.flags & TypeFlags.Anonymous)) {
|
||||
if (!(type.flags & TypeFlags.Anonymous) && type.symbol) {
|
||||
addRange(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments));
|
||||
}
|
||||
addSignatureDisplayParts(signature, allSignatures, TypeFormatFlags.WriteArrowStyleSignature);
|
||||
@@ -4311,7 +4398,7 @@ namespace ts {
|
||||
(location.kind === SyntaxKind.ConstructorKeyword && location.parent.kind === SyntaxKind.Constructor)) { // At constructor keyword of constructor declaration
|
||||
// get the signature from the declaration and write it
|
||||
const functionDeclaration = <FunctionLikeDeclaration>location.parent;
|
||||
const allSignatures = functionDeclaration.kind === SyntaxKind.Constructor ? type.getConstructSignatures() : type.getCallSignatures();
|
||||
const allSignatures = functionDeclaration.kind === SyntaxKind.Constructor ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures();
|
||||
if (!typeChecker.isImplementationOfOverload(functionDeclaration)) {
|
||||
signature = typeChecker.getSignatureFromDeclaration(functionDeclaration);
|
||||
}
|
||||
@@ -4509,7 +4596,7 @@ namespace ts {
|
||||
symbolFlags & SymbolFlags.Signature ||
|
||||
symbolFlags & SymbolFlags.Accessor ||
|
||||
symbolKind === ScriptElementKind.memberFunctionElement) {
|
||||
const allSignatures = type.getCallSignatures();
|
||||
const allSignatures = type.getNonNullableType().getCallSignatures();
|
||||
addSignatureDisplayParts(allSignatures[0], allSignatures);
|
||||
}
|
||||
}
|
||||
@@ -4590,7 +4677,7 @@ namespace ts {
|
||||
|
||||
const sourceFile = getValidSourceFile(fileName);
|
||||
const node = getTouchingPropertyName(sourceFile, position);
|
||||
if (!node) {
|
||||
if (node === sourceFile) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -4747,18 +4834,6 @@ namespace ts {
|
||||
|
||||
const sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
const node = getTouchingPropertyName(sourceFile, position);
|
||||
if (!node) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Labels
|
||||
if (isJumpStatementTarget(node)) {
|
||||
const labelName = (<Identifier>node).text;
|
||||
const label = getTargetLabel((<BreakOrContinueStatement>node.parent), (<Identifier>node).text);
|
||||
return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined;
|
||||
}
|
||||
|
||||
/// Triple slash reference comments
|
||||
const comment = findReferenceInPosition(sourceFile.referencedFiles, position);
|
||||
if (comment) {
|
||||
@@ -4768,6 +4843,7 @@ namespace ts {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Type reference directives
|
||||
const typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position);
|
||||
if (typeReferenceDirective) {
|
||||
@@ -4778,6 +4854,18 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const node = getTouchingPropertyName(sourceFile, position);
|
||||
if (node === sourceFile) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Labels
|
||||
if (isJumpStatementTarget(node)) {
|
||||
const labelName = (<Identifier>node).text;
|
||||
const label = getTargetLabel((<BreakOrContinueStatement>node.parent), (<Identifier>node).text);
|
||||
return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined;
|
||||
}
|
||||
|
||||
const typeChecker = program.getTypeChecker();
|
||||
let symbol = typeChecker.getSymbolAtLocation(node);
|
||||
|
||||
@@ -4836,7 +4924,7 @@ namespace ts {
|
||||
const sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
const node = getTouchingPropertyName(sourceFile, position);
|
||||
if (!node) {
|
||||
if (node === sourceFile) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -4886,8 +4974,7 @@ namespace ts {
|
||||
function getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] {
|
||||
synchronizeHostData();
|
||||
|
||||
filesToSearch = map(filesToSearch, normalizeSlashes);
|
||||
const sourceFilesToSearch = filter(program.getSourceFiles(), f => contains(filesToSearch, f.fileName));
|
||||
const sourceFilesToSearch = map(filesToSearch, f => program.getSourceFile(f));
|
||||
const sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
const node = getTouchingWord(sourceFile, position);
|
||||
@@ -5573,7 +5660,7 @@ namespace ts {
|
||||
const sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true);
|
||||
if (!node) {
|
||||
if (node === sourceFile) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -6231,7 +6318,8 @@ namespace ts {
|
||||
// If the location is name of property symbol from object literal destructuring pattern
|
||||
// Search the property symbol
|
||||
// for ( { property: p2 } of elems) { }
|
||||
if (isNameOfPropertyAssignment(location) && location.parent.kind !== SyntaxKind.ShorthandPropertyAssignment) {
|
||||
const containingObjectLiteralElement = getContainingObjectLiteralElement(location);
|
||||
if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== SyntaxKind.ShorthandPropertyAssignment) {
|
||||
const propertySymbol = getPropertySymbolOfDestructuringAssignment(location);
|
||||
if (propertySymbol) {
|
||||
result.push(propertySymbol);
|
||||
@@ -6257,8 +6345,8 @@ namespace ts {
|
||||
// If the location is in a context sensitive location (i.e. in an object literal) try
|
||||
// to get a contextual type for it, and add the property symbol from the contextual
|
||||
// type to the search set
|
||||
if (isNameOfPropertyAssignment(location)) {
|
||||
forEach(getPropertySymbolsFromContextualType(location), contextualSymbol => {
|
||||
if (containingObjectLiteralElement) {
|
||||
forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), contextualSymbol => {
|
||||
addRange(result, typeChecker.getRootSymbols(contextualSymbol));
|
||||
});
|
||||
|
||||
@@ -6385,8 +6473,9 @@ namespace ts {
|
||||
// If the reference location is in an object literal, try to get the contextual type for the
|
||||
// object literal, lookup the property symbol in the contextual type, and use this symbol to
|
||||
// compare to our searchSymbol
|
||||
if (isNameOfPropertyAssignment(referenceLocation)) {
|
||||
const contextualSymbol = forEach(getPropertySymbolsFromContextualType(referenceLocation), contextualSymbol => {
|
||||
const containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation);
|
||||
if (containingObjectLiteralElement) {
|
||||
const contextualSymbol = forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), contextualSymbol => {
|
||||
return forEach(typeChecker.getRootSymbols(contextualSymbol), s => searchSymbols.indexOf(s) >= 0 ? s : undefined);
|
||||
});
|
||||
|
||||
@@ -6432,37 +6521,38 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
function getPropertySymbolsFromContextualType(node: Node): Symbol[] {
|
||||
if (isNameOfPropertyAssignment(node)) {
|
||||
const objectLiteral = <ObjectLiteralExpression>node.parent.parent;
|
||||
const contextualType = typeChecker.getContextualType(objectLiteral);
|
||||
const name = (<Identifier>node).text;
|
||||
if (contextualType) {
|
||||
if (contextualType.flags & TypeFlags.Union) {
|
||||
// This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types)
|
||||
// if not, search the constituent types for the property
|
||||
const unionProperty = contextualType.getProperty(name);
|
||||
if (unionProperty) {
|
||||
return [unionProperty];
|
||||
}
|
||||
else {
|
||||
const result: Symbol[] = [];
|
||||
forEach((<UnionType>contextualType).types, t => {
|
||||
const symbol = t.getProperty(name);
|
||||
if (symbol) {
|
||||
result.push(symbol);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const symbol = contextualType.getProperty(name);
|
||||
if (symbol) {
|
||||
return [symbol];
|
||||
}
|
||||
}
|
||||
function getNameFromObjectLiteralElement(node: ObjectLiteralElement) {
|
||||
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
const nameExpression = (<ComputedPropertyName>node.name).expression;
|
||||
// treat computed property names where expression is string/numeric literal as just string/numeric literal
|
||||
if (isStringOrNumericLiteral(nameExpression.kind)) {
|
||||
return (<LiteralExpression>nameExpression).text;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
return (<Identifier | LiteralExpression>node.name).text;
|
||||
}
|
||||
|
||||
function getPropertySymbolsFromContextualType(node: ObjectLiteralElement): Symbol[] {
|
||||
const objectLiteral = <ObjectLiteralExpression>node.parent;
|
||||
const contextualType = typeChecker.getContextualType(objectLiteral);
|
||||
const name = getNameFromObjectLiteralElement(node);
|
||||
if (name && contextualType) {
|
||||
const result: Symbol[] = [];
|
||||
const symbol = contextualType.getProperty(name);
|
||||
if (symbol) {
|
||||
result.push(symbol);
|
||||
}
|
||||
|
||||
if (contextualType.flags & TypeFlags.Union) {
|
||||
forEach((<UnionType>contextualType).types, t => {
|
||||
const symbol = t.getProperty(name);
|
||||
if (symbol) {
|
||||
result.push(symbol);
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -6539,8 +6629,8 @@ namespace ts {
|
||||
/// NavigateTo
|
||||
function getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[] {
|
||||
synchronizeHostData();
|
||||
|
||||
return ts.NavigateTo.getNavigateToItems(program, cancellationToken, searchValue, maxResultCount);
|
||||
const checker = getProgram().getTypeChecker();
|
||||
return ts.NavigateTo.getNavigateToItems(program, checker, cancellationToken, searchValue, maxResultCount);
|
||||
}
|
||||
|
||||
function getEmitOutput(fileName: string): EmitOutput {
|
||||
@@ -6738,7 +6828,7 @@ namespace ts {
|
||||
// Get node at the location
|
||||
const node = getTouchingPropertyName(sourceFile, startPos);
|
||||
|
||||
if (!node) {
|
||||
if (node === sourceFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7924,7 +8014,8 @@ namespace ts {
|
||||
// "a['propname']" then we want to store "propname" in the name table.
|
||||
if (isDeclarationName(node) ||
|
||||
node.parent.kind === SyntaxKind.ExternalModuleReference ||
|
||||
isArgumentOfElementAccessExpression(node)) {
|
||||
isArgumentOfElementAccessExpression(node) ||
|
||||
isLiteralComputedPropertyDeclarationName(node)) {
|
||||
|
||||
nameTable[(<LiteralExpression>node).text] = nameTable[(<LiteralExpression>node).text] === undefined ? node.pos : -1;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ namespace ts {
|
||||
getLocalizedDiagnosticMessages(): string;
|
||||
getCancellationToken(): HostCancellationToken;
|
||||
getCurrentDirectory(): string;
|
||||
getDirectories(path: string): string[];
|
||||
getDefaultLibFileName(options: string): string;
|
||||
getNewLine?(): string;
|
||||
getProjectVersion?(): string;
|
||||
@@ -400,6 +401,10 @@ namespace ts {
|
||||
return this.shimHost.getCurrentDirectory();
|
||||
}
|
||||
|
||||
public getDirectories(path: string): string[] {
|
||||
return this.shimHost.getDirectories(path);
|
||||
}
|
||||
|
||||
public getDefaultLibFileName(options: CompilerOptions): string {
|
||||
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
|
||||
}
|
||||
@@ -431,11 +436,15 @@ namespace ts {
|
||||
export class CoreServicesShimHostAdapter implements ParseConfigHost, ModuleResolutionHost {
|
||||
|
||||
public directoryExists: (directoryName: string) => boolean;
|
||||
public realpath: (path: string) => string;
|
||||
|
||||
constructor(private shimHost: CoreServicesShimHost) {
|
||||
if ("directoryExists" in this.shimHost) {
|
||||
this.directoryExists = directoryName => this.shimHost.directoryExists(directoryName);
|
||||
}
|
||||
if ("realpath" in this.shimHost) {
|
||||
this.realpath = path => this.shimHost.realpath(path);
|
||||
}
|
||||
}
|
||||
|
||||
public readDirectory(rootDir: string, extension: string, exclude: string[], depth?: number): string[] {
|
||||
@@ -997,6 +1006,7 @@ namespace ts {
|
||||
options: {},
|
||||
typingOptions: {},
|
||||
files: [],
|
||||
raw: {},
|
||||
errors: [realizeDiagnostic(result.error, "\r\n")]
|
||||
};
|
||||
}
|
||||
@@ -1008,6 +1018,7 @@ namespace ts {
|
||||
options: configFile.options,
|
||||
typingOptions: configFile.typingOptions,
|
||||
files: configFile.fileNames,
|
||||
raw: configFile.raw,
|
||||
errors: realizeDiagnostics(configFile.errors, "\r\n")
|
||||
};
|
||||
});
|
||||
|
||||
@@ -395,7 +395,7 @@ namespace ts {
|
||||
if (lookInPreviousChild) {
|
||||
// actual start of the node is past the position - previous token should be at the end of previous child
|
||||
let candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i);
|
||||
return candidate && findRightmostToken(candidate)
|
||||
return candidate && findRightmostToken(candidate);
|
||||
}
|
||||
else {
|
||||
// candidate should be in this node
|
||||
@@ -519,8 +519,8 @@ namespace ts {
|
||||
return forEach(commentRanges, jsDocPrefix);
|
||||
|
||||
function jsDocPrefix(c: CommentRange): boolean {
|
||||
var text = sourceFile.text;
|
||||
return text.length >= c.pos + 3 && text[c.pos] === '/' && text[c.pos + 1] === '*' && text[c.pos + 2] === '*';
|
||||
const text = sourceFile.text;
|
||||
return text.length >= c.pos + 3 && text[c.pos] === "/" && text[c.pos + 1] === "*" && text[c.pos + 2] === "*";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -576,7 +576,7 @@ namespace ts {
|
||||
if (flags & NodeFlags.Export) result.push(ScriptElementKindModifier.exportedModifier);
|
||||
if (isInAmbientContext(node)) result.push(ScriptElementKindModifier.ambientModifier);
|
||||
|
||||
return result.length > 0 ? result.join(',') : ScriptElementKindModifier.none;
|
||||
return result.length > 0 ? result.join(",") : ScriptElementKindModifier.none;
|
||||
}
|
||||
|
||||
export function getTypeArgumentOrTypeParameterList(node: Node): NodeArray<Node> {
|
||||
@@ -741,7 +741,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function resetWriter() {
|
||||
displayParts = []
|
||||
displayParts = [];
|
||||
lineStart = true;
|
||||
indent = 0;
|
||||
}
|
||||
@@ -798,7 +798,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function textOrKeywordPart(text: string) {
|
||||
var kind = stringToToken(text);
|
||||
const kind = stringToToken(text);
|
||||
return kind === undefined
|
||||
? textPart(text)
|
||||
: keywordPart(kind);
|
||||
@@ -851,6 +851,10 @@ namespace ts {
|
||||
if (isImportOrExportSpecifierName(location)) {
|
||||
return location.getText();
|
||||
}
|
||||
else if (isStringOrNumericLiteral(location.kind) &&
|
||||
location.parent.kind === SyntaxKind.ComputedPropertyName) {
|
||||
return (<LiteralExpression>location).text;
|
||||
}
|
||||
|
||||
// Try to get the local symbol if we're dealing with an 'export default'
|
||||
// since that symbol has the "true" name.
|
||||
|
||||
@@ -12,3 +12,4 @@ var C = (function () {
|
||||
return C;
|
||||
}());
|
||||
exports.C = C;
|
||||
module.exports = B;
|
||||
@@ -12,3 +12,4 @@ var C = (function () {
|
||||
return C;
|
||||
}());
|
||||
exports.C = C;
|
||||
module.exports = B;
|
||||
@@ -1,20 +1,14 @@
|
||||
tests/cases/compiler/accessorParameterAccessibilityModifier.ts(3,9): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
tests/cases/compiler/accessorParameterAccessibilityModifier.ts(3,11): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
tests/cases/compiler/accessorParameterAccessibilityModifier.ts(4,16): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
tests/cases/compiler/accessorParameterAccessibilityModifier.ts(4,18): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
|
||||
|
||||
==== tests/cases/compiler/accessorParameterAccessibilityModifier.ts (4 errors) ====
|
||||
==== tests/cases/compiler/accessorParameterAccessibilityModifier.ts (2 errors) ====
|
||||
|
||||
class C {
|
||||
set X(public v) { }
|
||||
~
|
||||
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
~~~~~~~~
|
||||
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
static set X(public v2) { }
|
||||
~
|
||||
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
~~~~~~~~~
|
||||
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
}
|
||||
@@ -55,9 +55,12 @@ var foo;
|
||||
var provide = foo;
|
||||
var booz = foo.bar.baz;
|
||||
var beez = foo.bar;
|
||||
var m = no;
|
||||
var m2 = no.mod;
|
||||
5;
|
||||
"s";
|
||||
null;
|
||||
var r = undefined;
|
||||
var p = new provide.Provide();
|
||||
function use() {
|
||||
beez.baz.boo;
|
||||
|
||||
@@ -9,9 +9,9 @@ function doubleAndReturnAsArray(x: number, y: number, z: number): [number, numbe
|
||||
let blah = arguments[Symbol.iterator];
|
||||
>blah : Symbol(blah, Decl(argumentsObjectIterator02_ES6.ts, 2, 7))
|
||||
>arguments : Symbol(arguments)
|
||||
>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
|
||||
>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
|
||||
let result = [];
|
||||
>result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7))
|
||||
|
||||
@@ -79,7 +79,7 @@ interface myArray2 extends Array<Number|String> { }
|
||||
>myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES6.ts, 42, 43))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
|
||||
>Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
|
||||
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
|
||||
|
||||
var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[]
|
||||
>d0 : Symbol(d0, Decl(arrayLiterals2ES6.ts, 44, 3))
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
//// [arrowFunctionWithParameterNameAsync.ts]
|
||||
|
||||
const x = async => async;
|
||||
|
||||
//// [arrowFunctionWithParameterNameAsync.js]
|
||||
var x = function (async) { return async; };
|
||||
@@ -0,0 +1,7 @@
|
||||
=== tests/cases/conformance/async/es6/asyncArrowFunction/arrowFunctionWithParameterNameAsync.ts ===
|
||||
|
||||
const x = async => async;
|
||||
>x : Symbol(x, Decl(arrowFunctionWithParameterNameAsync.ts, 1, 5))
|
||||
>async : Symbol(async, Decl(arrowFunctionWithParameterNameAsync.ts, 1, 9))
|
||||
>async : Symbol(async, Decl(arrowFunctionWithParameterNameAsync.ts, 1, 9))
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/conformance/async/es6/asyncArrowFunction/arrowFunctionWithParameterNameAsync.ts ===
|
||||
|
||||
const x = async => async;
|
||||
>x : (async: any) => any
|
||||
>async => async : (async: any) => any
|
||||
>async : any
|
||||
>async : any
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
//// [asyncFunctionsAndStrictNullChecks.ts]
|
||||
|
||||
declare namespace Windows.Foundation {
|
||||
interface IPromise<TResult> {
|
||||
then<U>(success?: (value: TResult) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>;
|
||||
then<U>(success?: (value: TResult) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
|
||||
then<U>(success?: (value: TResult) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>;
|
||||
then<U>(success?: (value: TResult) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
|
||||
done<U>(success?: (value: TResult) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
|
||||
|
||||
cancel(): void;
|
||||
}
|
||||
}
|
||||
|
||||
async function sample(promise: Windows.Foundation.IPromise<number>) {
|
||||
var number = await promise;
|
||||
}
|
||||
|
||||
|
||||
declare function resolve1<T>(value: T): Promise<T>;
|
||||
declare function resolve2<T>(value: T): Windows.Foundation.IPromise<T>;
|
||||
|
||||
async function sample2(x?: number) {
|
||||
let x1 = await resolve1(x);
|
||||
let x2 = await resolve2(x);
|
||||
}
|
||||
|
||||
|
||||
//// [asyncFunctionsAndStrictNullChecks.js]
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
};
|
||||
function sample(promise) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var number = yield promise;
|
||||
});
|
||||
}
|
||||
function sample2(x) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let x1 = yield resolve1(x);
|
||||
let x2 = yield resolve2(x);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
=== tests/cases/compiler/asyncFunctionsAndStrictNullChecks.ts ===
|
||||
|
||||
declare namespace Windows.Foundation {
|
||||
>Windows : Symbol(Windows, Decl(asyncFunctionsAndStrictNullChecks.ts, 0, 0))
|
||||
>Foundation : Symbol(Foundation, Decl(asyncFunctionsAndStrictNullChecks.ts, 1, 26))
|
||||
|
||||
interface IPromise<TResult> {
|
||||
>IPromise : Symbol(IPromise, Decl(asyncFunctionsAndStrictNullChecks.ts, 1, 38))
|
||||
>TResult : Symbol(TResult, Decl(asyncFunctionsAndStrictNullChecks.ts, 2, 23))
|
||||
|
||||
then<U>(success?: (value: TResult) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>;
|
||||
>then : Symbol(IPromise.then, Decl(asyncFunctionsAndStrictNullChecks.ts, 2, 33), Decl(asyncFunctionsAndStrictNullChecks.ts, 3, 145), Decl(asyncFunctionsAndStrictNullChecks.ts, 4, 135), Decl(asyncFunctionsAndStrictNullChecks.ts, 5, 135))
|
||||
>U : Symbol(U, Decl(asyncFunctionsAndStrictNullChecks.ts, 3, 13))
|
||||
>success : Symbol(success, Decl(asyncFunctionsAndStrictNullChecks.ts, 3, 16))
|
||||
>value : Symbol(value, Decl(asyncFunctionsAndStrictNullChecks.ts, 3, 27))
|
||||
>TResult : Symbol(TResult, Decl(asyncFunctionsAndStrictNullChecks.ts, 2, 23))
|
||||
>IPromise : Symbol(IPromise, Decl(asyncFunctionsAndStrictNullChecks.ts, 1, 38))
|
||||
>U : Symbol(U, Decl(asyncFunctionsAndStrictNullChecks.ts, 3, 13))
|
||||
>error : Symbol(error, Decl(asyncFunctionsAndStrictNullChecks.ts, 3, 58))
|
||||
>error : Symbol(error, Decl(asyncFunctionsAndStrictNullChecks.ts, 3, 68))
|
||||
>IPromise : Symbol(IPromise, Decl(asyncFunctionsAndStrictNullChecks.ts, 1, 38))
|
||||
>U : Symbol(U, Decl(asyncFunctionsAndStrictNullChecks.ts, 3, 13))
|
||||
>progress : Symbol(progress, Decl(asyncFunctionsAndStrictNullChecks.ts, 3, 95))
|
||||
>progress : Symbol(progress, Decl(asyncFunctionsAndStrictNullChecks.ts, 3, 108))
|
||||
>IPromise : Symbol(IPromise, Decl(asyncFunctionsAndStrictNullChecks.ts, 1, 38))
|
||||
>U : Symbol(U, Decl(asyncFunctionsAndStrictNullChecks.ts, 3, 13))
|
||||
|
||||
then<U>(success?: (value: TResult) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
|
||||
>then : Symbol(IPromise.then, Decl(asyncFunctionsAndStrictNullChecks.ts, 2, 33), Decl(asyncFunctionsAndStrictNullChecks.ts, 3, 145), Decl(asyncFunctionsAndStrictNullChecks.ts, 4, 135), Decl(asyncFunctionsAndStrictNullChecks.ts, 5, 135))
|
||||
>U : Symbol(U, Decl(asyncFunctionsAndStrictNullChecks.ts, 4, 13))
|
||||
>success : Symbol(success, Decl(asyncFunctionsAndStrictNullChecks.ts, 4, 16))
|
||||
>value : Symbol(value, Decl(asyncFunctionsAndStrictNullChecks.ts, 4, 27))
|
||||
>TResult : Symbol(TResult, Decl(asyncFunctionsAndStrictNullChecks.ts, 2, 23))
|
||||
>IPromise : Symbol(IPromise, Decl(asyncFunctionsAndStrictNullChecks.ts, 1, 38))
|
||||
>U : Symbol(U, Decl(asyncFunctionsAndStrictNullChecks.ts, 4, 13))
|
||||
>error : Symbol(error, Decl(asyncFunctionsAndStrictNullChecks.ts, 4, 58))
|
||||
>error : Symbol(error, Decl(asyncFunctionsAndStrictNullChecks.ts, 4, 68))
|
||||
>U : Symbol(U, Decl(asyncFunctionsAndStrictNullChecks.ts, 4, 13))
|
||||
>progress : Symbol(progress, Decl(asyncFunctionsAndStrictNullChecks.ts, 4, 85))
|
||||
>progress : Symbol(progress, Decl(asyncFunctionsAndStrictNullChecks.ts, 4, 98))
|
||||
>IPromise : Symbol(IPromise, Decl(asyncFunctionsAndStrictNullChecks.ts, 1, 38))
|
||||
>U : Symbol(U, Decl(asyncFunctionsAndStrictNullChecks.ts, 4, 13))
|
||||
|
||||
then<U>(success?: (value: TResult) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>;
|
||||
>then : Symbol(IPromise.then, Decl(asyncFunctionsAndStrictNullChecks.ts, 2, 33), Decl(asyncFunctionsAndStrictNullChecks.ts, 3, 145), Decl(asyncFunctionsAndStrictNullChecks.ts, 4, 135), Decl(asyncFunctionsAndStrictNullChecks.ts, 5, 135))
|
||||
>U : Symbol(U, Decl(asyncFunctionsAndStrictNullChecks.ts, 5, 13))
|
||||
>success : Symbol(success, Decl(asyncFunctionsAndStrictNullChecks.ts, 5, 16))
|
||||
>value : Symbol(value, Decl(asyncFunctionsAndStrictNullChecks.ts, 5, 27))
|
||||
>TResult : Symbol(TResult, Decl(asyncFunctionsAndStrictNullChecks.ts, 2, 23))
|
||||
>U : Symbol(U, Decl(asyncFunctionsAndStrictNullChecks.ts, 5, 13))
|
||||
>error : Symbol(error, Decl(asyncFunctionsAndStrictNullChecks.ts, 5, 48))
|
||||
>error : Symbol(error, Decl(asyncFunctionsAndStrictNullChecks.ts, 5, 58))
|
||||
>IPromise : Symbol(IPromise, Decl(asyncFunctionsAndStrictNullChecks.ts, 1, 38))
|
||||
>U : Symbol(U, Decl(asyncFunctionsAndStrictNullChecks.ts, 5, 13))
|
||||
>progress : Symbol(progress, Decl(asyncFunctionsAndStrictNullChecks.ts, 5, 85))
|
||||
>progress : Symbol(progress, Decl(asyncFunctionsAndStrictNullChecks.ts, 5, 98))
|
||||
>IPromise : Symbol(IPromise, Decl(asyncFunctionsAndStrictNullChecks.ts, 1, 38))
|
||||
>U : Symbol(U, Decl(asyncFunctionsAndStrictNullChecks.ts, 5, 13))
|
||||
|
||||
then<U>(success?: (value: TResult) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
|
||||
>then : Symbol(IPromise.then, Decl(asyncFunctionsAndStrictNullChecks.ts, 2, 33), Decl(asyncFunctionsAndStrictNullChecks.ts, 3, 145), Decl(asyncFunctionsAndStrictNullChecks.ts, 4, 135), Decl(asyncFunctionsAndStrictNullChecks.ts, 5, 135))
|
||||
>U : Symbol(U, Decl(asyncFunctionsAndStrictNullChecks.ts, 6, 13))
|
||||
>success : Symbol(success, Decl(asyncFunctionsAndStrictNullChecks.ts, 6, 16))
|
||||
>value : Symbol(value, Decl(asyncFunctionsAndStrictNullChecks.ts, 6, 27))
|
||||
>TResult : Symbol(TResult, Decl(asyncFunctionsAndStrictNullChecks.ts, 2, 23))
|
||||
>U : Symbol(U, Decl(asyncFunctionsAndStrictNullChecks.ts, 6, 13))
|
||||
>error : Symbol(error, Decl(asyncFunctionsAndStrictNullChecks.ts, 6, 48))
|
||||
>error : Symbol(error, Decl(asyncFunctionsAndStrictNullChecks.ts, 6, 58))
|
||||
>U : Symbol(U, Decl(asyncFunctionsAndStrictNullChecks.ts, 6, 13))
|
||||
>progress : Symbol(progress, Decl(asyncFunctionsAndStrictNullChecks.ts, 6, 75))
|
||||
>progress : Symbol(progress, Decl(asyncFunctionsAndStrictNullChecks.ts, 6, 88))
|
||||
>IPromise : Symbol(IPromise, Decl(asyncFunctionsAndStrictNullChecks.ts, 1, 38))
|
||||
>U : Symbol(U, Decl(asyncFunctionsAndStrictNullChecks.ts, 6, 13))
|
||||
|
||||
done<U>(success?: (value: TResult) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
|
||||
>done : Symbol(IPromise.done, Decl(asyncFunctionsAndStrictNullChecks.ts, 6, 125))
|
||||
>U : Symbol(U, Decl(asyncFunctionsAndStrictNullChecks.ts, 7, 13))
|
||||
>success : Symbol(success, Decl(asyncFunctionsAndStrictNullChecks.ts, 7, 16))
|
||||
>value : Symbol(value, Decl(asyncFunctionsAndStrictNullChecks.ts, 7, 27))
|
||||
>TResult : Symbol(TResult, Decl(asyncFunctionsAndStrictNullChecks.ts, 2, 23))
|
||||
>error : Symbol(error, Decl(asyncFunctionsAndStrictNullChecks.ts, 7, 50))
|
||||
>error : Symbol(error, Decl(asyncFunctionsAndStrictNullChecks.ts, 7, 60))
|
||||
>progress : Symbol(progress, Decl(asyncFunctionsAndStrictNullChecks.ts, 7, 79))
|
||||
>progress : Symbol(progress, Decl(asyncFunctionsAndStrictNullChecks.ts, 7, 92))
|
||||
|
||||
cancel(): void;
|
||||
>cancel : Symbol(IPromise.cancel, Decl(asyncFunctionsAndStrictNullChecks.ts, 7, 122))
|
||||
}
|
||||
}
|
||||
|
||||
async function sample(promise: Windows.Foundation.IPromise<number>) {
|
||||
>sample : Symbol(sample, Decl(asyncFunctionsAndStrictNullChecks.ts, 11, 1))
|
||||
>promise : Symbol(promise, Decl(asyncFunctionsAndStrictNullChecks.ts, 13, 22))
|
||||
>Windows : Symbol(Windows, Decl(asyncFunctionsAndStrictNullChecks.ts, 0, 0))
|
||||
>Foundation : Symbol(Windows.Foundation, Decl(asyncFunctionsAndStrictNullChecks.ts, 1, 26))
|
||||
>IPromise : Symbol(Windows.Foundation.IPromise, Decl(asyncFunctionsAndStrictNullChecks.ts, 1, 38))
|
||||
|
||||
var number = await promise;
|
||||
>number : Symbol(number, Decl(asyncFunctionsAndStrictNullChecks.ts, 14, 7))
|
||||
>promise : Symbol(promise, Decl(asyncFunctionsAndStrictNullChecks.ts, 13, 22))
|
||||
}
|
||||
|
||||
|
||||
declare function resolve1<T>(value: T): Promise<T>;
|
||||
>resolve1 : Symbol(resolve1, Decl(asyncFunctionsAndStrictNullChecks.ts, 15, 1))
|
||||
>T : Symbol(T, Decl(asyncFunctionsAndStrictNullChecks.ts, 18, 26))
|
||||
>value : Symbol(value, Decl(asyncFunctionsAndStrictNullChecks.ts, 18, 29))
|
||||
>T : Symbol(T, Decl(asyncFunctionsAndStrictNullChecks.ts, 18, 26))
|
||||
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(asyncFunctionsAndStrictNullChecks.ts, 18, 26))
|
||||
|
||||
declare function resolve2<T>(value: T): Windows.Foundation.IPromise<T>;
|
||||
>resolve2 : Symbol(resolve2, Decl(asyncFunctionsAndStrictNullChecks.ts, 18, 51))
|
||||
>T : Symbol(T, Decl(asyncFunctionsAndStrictNullChecks.ts, 19, 26))
|
||||
>value : Symbol(value, Decl(asyncFunctionsAndStrictNullChecks.ts, 19, 29))
|
||||
>T : Symbol(T, Decl(asyncFunctionsAndStrictNullChecks.ts, 19, 26))
|
||||
>Windows : Symbol(Windows, Decl(asyncFunctionsAndStrictNullChecks.ts, 0, 0))
|
||||
>Foundation : Symbol(Windows.Foundation, Decl(asyncFunctionsAndStrictNullChecks.ts, 1, 26))
|
||||
>IPromise : Symbol(Windows.Foundation.IPromise, Decl(asyncFunctionsAndStrictNullChecks.ts, 1, 38))
|
||||
>T : Symbol(T, Decl(asyncFunctionsAndStrictNullChecks.ts, 19, 26))
|
||||
|
||||
async function sample2(x?: number) {
|
||||
>sample2 : Symbol(sample2, Decl(asyncFunctionsAndStrictNullChecks.ts, 19, 71))
|
||||
>x : Symbol(x, Decl(asyncFunctionsAndStrictNullChecks.ts, 21, 23))
|
||||
|
||||
let x1 = await resolve1(x);
|
||||
>x1 : Symbol(x1, Decl(asyncFunctionsAndStrictNullChecks.ts, 22, 7))
|
||||
>resolve1 : Symbol(resolve1, Decl(asyncFunctionsAndStrictNullChecks.ts, 15, 1))
|
||||
>x : Symbol(x, Decl(asyncFunctionsAndStrictNullChecks.ts, 21, 23))
|
||||
|
||||
let x2 = await resolve2(x);
|
||||
>x2 : Symbol(x2, Decl(asyncFunctionsAndStrictNullChecks.ts, 23, 7))
|
||||
>resolve2 : Symbol(resolve2, Decl(asyncFunctionsAndStrictNullChecks.ts, 18, 51))
|
||||
>x : Symbol(x, Decl(asyncFunctionsAndStrictNullChecks.ts, 21, 23))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
=== tests/cases/compiler/asyncFunctionsAndStrictNullChecks.ts ===
|
||||
|
||||
declare namespace Windows.Foundation {
|
||||
>Windows : any
|
||||
>Foundation : any
|
||||
|
||||
interface IPromise<TResult> {
|
||||
>IPromise : IPromise<TResult>
|
||||
>TResult : TResult
|
||||
|
||||
then<U>(success?: (value: TResult) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>;
|
||||
>then : { <U>(success?: ((value: TResult) => IPromise<U>) | undefined, error?: ((error: any) => IPromise<U>) | undefined, progress?: ((progress: any) => void) | undefined): IPromise<U>; <U>(success?: ((value: TResult) => IPromise<U>) | undefined, error?: ((error: any) => U) | undefined, progress?: ((progress: any) => void) | undefined): IPromise<U>; <U>(success?: ((value: TResult) => U) | undefined, error?: ((error: any) => IPromise<U>) | undefined, progress?: ((progress: any) => void) | undefined): IPromise<U>; <U>(success?: ((value: TResult) => U) | undefined, error?: ((error: any) => U) | undefined, progress?: ((progress: any) => void) | undefined): IPromise<U>; }
|
||||
>U : U
|
||||
>success : ((value: TResult) => IPromise<U>) | undefined
|
||||
>value : TResult
|
||||
>TResult : TResult
|
||||
>IPromise : IPromise<TResult>
|
||||
>U : U
|
||||
>error : ((error: any) => IPromise<U>) | undefined
|
||||
>error : any
|
||||
>IPromise : IPromise<TResult>
|
||||
>U : U
|
||||
>progress : ((progress: any) => void) | undefined
|
||||
>progress : any
|
||||
>IPromise : IPromise<TResult>
|
||||
>U : U
|
||||
|
||||
then<U>(success?: (value: TResult) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
|
||||
>then : { <U>(success?: ((value: TResult) => IPromise<U>) | undefined, error?: ((error: any) => IPromise<U>) | undefined, progress?: ((progress: any) => void) | undefined): IPromise<U>; <U>(success?: ((value: TResult) => IPromise<U>) | undefined, error?: ((error: any) => U) | undefined, progress?: ((progress: any) => void) | undefined): IPromise<U>; <U>(success?: ((value: TResult) => U) | undefined, error?: ((error: any) => IPromise<U>) | undefined, progress?: ((progress: any) => void) | undefined): IPromise<U>; <U>(success?: ((value: TResult) => U) | undefined, error?: ((error: any) => U) | undefined, progress?: ((progress: any) => void) | undefined): IPromise<U>; }
|
||||
>U : U
|
||||
>success : ((value: TResult) => IPromise<U>) | undefined
|
||||
>value : TResult
|
||||
>TResult : TResult
|
||||
>IPromise : IPromise<TResult>
|
||||
>U : U
|
||||
>error : ((error: any) => U) | undefined
|
||||
>error : any
|
||||
>U : U
|
||||
>progress : ((progress: any) => void) | undefined
|
||||
>progress : any
|
||||
>IPromise : IPromise<TResult>
|
||||
>U : U
|
||||
|
||||
then<U>(success?: (value: TResult) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>;
|
||||
>then : { <U>(success?: ((value: TResult) => IPromise<U>) | undefined, error?: ((error: any) => IPromise<U>) | undefined, progress?: ((progress: any) => void) | undefined): IPromise<U>; <U>(success?: ((value: TResult) => IPromise<U>) | undefined, error?: ((error: any) => U) | undefined, progress?: ((progress: any) => void) | undefined): IPromise<U>; <U>(success?: ((value: TResult) => U) | undefined, error?: ((error: any) => IPromise<U>) | undefined, progress?: ((progress: any) => void) | undefined): IPromise<U>; <U>(success?: ((value: TResult) => U) | undefined, error?: ((error: any) => U) | undefined, progress?: ((progress: any) => void) | undefined): IPromise<U>; }
|
||||
>U : U
|
||||
>success : ((value: TResult) => U) | undefined
|
||||
>value : TResult
|
||||
>TResult : TResult
|
||||
>U : U
|
||||
>error : ((error: any) => IPromise<U>) | undefined
|
||||
>error : any
|
||||
>IPromise : IPromise<TResult>
|
||||
>U : U
|
||||
>progress : ((progress: any) => void) | undefined
|
||||
>progress : any
|
||||
>IPromise : IPromise<TResult>
|
||||
>U : U
|
||||
|
||||
then<U>(success?: (value: TResult) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
|
||||
>then : { <U>(success?: ((value: TResult) => IPromise<U>) | undefined, error?: ((error: any) => IPromise<U>) | undefined, progress?: ((progress: any) => void) | undefined): IPromise<U>; <U>(success?: ((value: TResult) => IPromise<U>) | undefined, error?: ((error: any) => U) | undefined, progress?: ((progress: any) => void) | undefined): IPromise<U>; <U>(success?: ((value: TResult) => U) | undefined, error?: ((error: any) => IPromise<U>) | undefined, progress?: ((progress: any) => void) | undefined): IPromise<U>; <U>(success?: ((value: TResult) => U) | undefined, error?: ((error: any) => U) | undefined, progress?: ((progress: any) => void) | undefined): IPromise<U>; }
|
||||
>U : U
|
||||
>success : ((value: TResult) => U) | undefined
|
||||
>value : TResult
|
||||
>TResult : TResult
|
||||
>U : U
|
||||
>error : ((error: any) => U) | undefined
|
||||
>error : any
|
||||
>U : U
|
||||
>progress : ((progress: any) => void) | undefined
|
||||
>progress : any
|
||||
>IPromise : IPromise<TResult>
|
||||
>U : U
|
||||
|
||||
done<U>(success?: (value: TResult) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
|
||||
>done : <U>(success?: ((value: TResult) => any) | undefined, error?: ((error: any) => any) | undefined, progress?: ((progress: any) => void) | undefined) => void
|
||||
>U : U
|
||||
>success : ((value: TResult) => any) | undefined
|
||||
>value : TResult
|
||||
>TResult : TResult
|
||||
>error : ((error: any) => any) | undefined
|
||||
>error : any
|
||||
>progress : ((progress: any) => void) | undefined
|
||||
>progress : any
|
||||
|
||||
cancel(): void;
|
||||
>cancel : () => void
|
||||
}
|
||||
}
|
||||
|
||||
async function sample(promise: Windows.Foundation.IPromise<number>) {
|
||||
>sample : (promise: Windows.Foundation.IPromise<number>) => Promise<void>
|
||||
>promise : Windows.Foundation.IPromise<number>
|
||||
>Windows : any
|
||||
>Foundation : any
|
||||
>IPromise : Windows.Foundation.IPromise<TResult>
|
||||
|
||||
var number = await promise;
|
||||
>number : number
|
||||
>await promise : number
|
||||
>promise : Windows.Foundation.IPromise<number>
|
||||
}
|
||||
|
||||
|
||||
declare function resolve1<T>(value: T): Promise<T>;
|
||||
>resolve1 : <T>(value: T) => Promise<T>
|
||||
>T : T
|
||||
>value : T
|
||||
>T : T
|
||||
>Promise : Promise<T>
|
||||
>T : T
|
||||
|
||||
declare function resolve2<T>(value: T): Windows.Foundation.IPromise<T>;
|
||||
>resolve2 : <T>(value: T) => Windows.Foundation.IPromise<T>
|
||||
>T : T
|
||||
>value : T
|
||||
>T : T
|
||||
>Windows : any
|
||||
>Foundation : any
|
||||
>IPromise : Windows.Foundation.IPromise<TResult>
|
||||
>T : T
|
||||
|
||||
async function sample2(x?: number) {
|
||||
>sample2 : (x?: number | undefined) => Promise<void>
|
||||
>x : number | undefined
|
||||
|
||||
let x1 = await resolve1(x);
|
||||
>x1 : number | undefined
|
||||
>await resolve1(x) : number | undefined
|
||||
>resolve1(x) : Promise<number | undefined>
|
||||
>resolve1 : <T>(value: T) => Promise<T>
|
||||
>x : number | undefined
|
||||
|
||||
let x2 = await resolve2(x);
|
||||
>x2 : number | undefined
|
||||
>await resolve2(x) : number | undefined
|
||||
>resolve2(x) : Windows.Foundation.IPromise<number | undefined>
|
||||
>resolve2 : <T>(value: T) => Windows.Foundation.IPromise<T>
|
||||
>x : number | undefined
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
//// [asyncUnParenthesizedArrowFunction_es6.ts]
|
||||
|
||||
declare function someOtherFunction(i: any): Promise<void>;
|
||||
const x = async i => await someOtherFunction(i)
|
||||
const x1 = async (i) => await someOtherFunction(i);
|
||||
|
||||
//// [asyncUnParenthesizedArrowFunction_es6.js]
|
||||
const x = (i) => __awaiter(this, void 0, void 0, function* () { return yield someOtherFunction(i); });
|
||||
const x1 = (i) => __awaiter(this, void 0, void 0, function* () { return yield someOtherFunction(i); });
|
||||
@@ -0,0 +1,19 @@
|
||||
=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es6.ts ===
|
||||
|
||||
declare function someOtherFunction(i: any): Promise<void>;
|
||||
>someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 0, 0))
|
||||
>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 1, 35))
|
||||
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
|
||||
const x = async i => await someOtherFunction(i)
|
||||
>x : Symbol(x, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 2, 5))
|
||||
>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 2, 15))
|
||||
>someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 0, 0))
|
||||
>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 2, 15))
|
||||
|
||||
const x1 = async (i) => await someOtherFunction(i);
|
||||
>x1 : Symbol(x1, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 3, 5))
|
||||
>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 3, 18))
|
||||
>someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 0, 0))
|
||||
>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 3, 18))
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es6.ts ===
|
||||
|
||||
declare function someOtherFunction(i: any): Promise<void>;
|
||||
>someOtherFunction : (i: any) => Promise<void>
|
||||
>i : any
|
||||
>Promise : Promise<T>
|
||||
|
||||
const x = async i => await someOtherFunction(i)
|
||||
>x : (i: any) => Promise<void>
|
||||
>async i => await someOtherFunction(i) : (i: any) => Promise<void>
|
||||
>i : any
|
||||
>await someOtherFunction(i) : void
|
||||
>someOtherFunction(i) : Promise<void>
|
||||
>someOtherFunction : (i: any) => Promise<void>
|
||||
>i : any
|
||||
|
||||
const x1 = async (i) => await someOtherFunction(i);
|
||||
>x1 : (i: any) => Promise<void>
|
||||
>async (i) => await someOtherFunction(i) : (i: any) => Promise<void>
|
||||
>i : any
|
||||
>await someOtherFunction(i) : void
|
||||
>someOtherFunction(i) : Promise<void>
|
||||
>someOtherFunction : (i: any) => Promise<void>
|
||||
>i : any
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
tests/cases/compiler/file2.ts(6,15): error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
tests/cases/compiler/file2.ts(7,9): error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (0 errors) ====
|
||||
|
||||
function foo() {}
|
||||
namespace foo {
|
||||
export var v = 1;
|
||||
}
|
||||
export = foo;
|
||||
|
||||
==== tests/cases/compiler/file2.ts (2 errors) ====
|
||||
import x = require("./file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
~
|
||||
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
let b: number;
|
||||
~
|
||||
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/file3.ts (0 errors) ====
|
||||
import * as x from "./file1";
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
@@ -0,0 +1,49 @@
|
||||
=== tests/cases/compiler/file1.ts ===
|
||||
|
||||
function foo() {}
|
||||
>foo : Symbol(, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 17), Decl(file2.ts, 1, 8))
|
||||
|
||||
namespace foo {
|
||||
>foo : Symbol(, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 17), Decl(file2.ts, 1, 8))
|
||||
|
||||
export var v = 1;
|
||||
>v : Symbol(v, Decl(file1.ts, 3, 14))
|
||||
}
|
||||
export = foo;
|
||||
>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 17))
|
||||
|
||||
=== tests/cases/compiler/file2.ts ===
|
||||
import x = require("./file1");
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 0))
|
||||
|
||||
x.b = 1;
|
||||
>x.b : Symbol(x.b, Decl(file2.ts, 6, 7))
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 0))
|
||||
>b : Symbol(x.b, Decl(file2.ts, 6, 7))
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
>A : Symbol(A, Decl(file2.ts, 4, 26))
|
||||
>a : Symbol(A.a, Decl(file2.ts, 5, 17))
|
||||
|
||||
let b: number;
|
||||
>b : Symbol(b, Decl(file2.ts, 6, 7))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/file3.ts ===
|
||||
import * as x from "./file1";
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 6))
|
||||
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
>a : Symbol(a, Decl(file3.ts, 2, 3))
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 6))
|
||||
>A : Symbol(x.A, Decl(file2.ts, 4, 26))
|
||||
|
||||
let b = x.b;
|
||||
>b : Symbol(b, Decl(file3.ts, 3, 3))
|
||||
>x.b : Symbol(x.b, Decl(file2.ts, 6, 7))
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 6))
|
||||
>b : Symbol(x.b, Decl(file2.ts, 6, 7))
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
=== tests/cases/compiler/file1.ts ===
|
||||
|
||||
function foo() {}
|
||||
>foo : typeof
|
||||
|
||||
namespace foo {
|
||||
>foo : typeof
|
||||
|
||||
export var v = 1;
|
||||
>v : number
|
||||
>1 : number
|
||||
}
|
||||
export = foo;
|
||||
>foo : typeof foo
|
||||
|
||||
=== tests/cases/compiler/file2.ts ===
|
||||
import x = require("./file1");
|
||||
>x : typeof x
|
||||
|
||||
x.b = 1;
|
||||
>x.b = 1 : number
|
||||
>x.b : number
|
||||
>x : typeof x
|
||||
>b : number
|
||||
>1 : number
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
>A : A
|
||||
>a : any
|
||||
|
||||
let b: number;
|
||||
>b : number
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/file3.ts ===
|
||||
import * as x from "./file1";
|
||||
>x : typeof x
|
||||
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
>a : x.A
|
||||
>x : any
|
||||
>A : x.A
|
||||
|
||||
let b = x.b;
|
||||
>b : number
|
||||
>x.b : number
|
||||
>x : typeof x
|
||||
>b : number
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
tests/cases/compiler/file2.ts(7,15): error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
tests/cases/compiler/file2.ts(8,9): error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.d.ts (0 errors) ====
|
||||
declare module "file1" {
|
||||
function foo(): void;
|
||||
namespace foo {
|
||||
export var v: number;
|
||||
}
|
||||
export = foo;
|
||||
}
|
||||
|
||||
|
||||
==== tests/cases/compiler/file2.ts (2 errors) ====
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
~
|
||||
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
let b: number;
|
||||
~
|
||||
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/file3.ts (0 errors) ====
|
||||
import * as x from "file1";
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
@@ -0,0 +1,52 @@
|
||||
=== tests/cases/compiler/file1.d.ts ===
|
||||
declare module "file1" {
|
||||
function foo(): void;
|
||||
>foo : Symbol(, Decl(file1.d.ts, 0, 24), Decl(file1.d.ts, 1, 25), Decl(file2.ts, 2, 8))
|
||||
|
||||
namespace foo {
|
||||
>foo : Symbol(, Decl(file1.d.ts, 0, 24), Decl(file1.d.ts, 1, 25), Decl(file2.ts, 2, 8))
|
||||
|
||||
export var v: number;
|
||||
>v : Symbol(v, Decl(file1.d.ts, 3, 18))
|
||||
}
|
||||
export = foo;
|
||||
>foo : Symbol(foo, Decl(file1.d.ts, 0, 24), Decl(file1.d.ts, 1, 25))
|
||||
}
|
||||
|
||||
|
||||
=== tests/cases/compiler/file2.ts ===
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 0))
|
||||
|
||||
x.b = 1;
|
||||
>x.b : Symbol(x.b, Decl(file2.ts, 7, 7))
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 0))
|
||||
>b : Symbol(x.b, Decl(file2.ts, 7, 7))
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
>A : Symbol(A, Decl(file2.ts, 5, 24))
|
||||
>a : Symbol(A.a, Decl(file2.ts, 6, 17))
|
||||
|
||||
let b: number;
|
||||
>b : Symbol(b, Decl(file2.ts, 7, 7))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/file3.ts ===
|
||||
import * as x from "file1";
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 6))
|
||||
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
>a : Symbol(a, Decl(file3.ts, 2, 3))
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 6))
|
||||
>A : Symbol(x.A, Decl(file2.ts, 5, 24))
|
||||
|
||||
let b = x.b;
|
||||
>b : Symbol(b, Decl(file3.ts, 3, 3))
|
||||
>x.b : Symbol(x.b, Decl(file2.ts, 7, 7))
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 6))
|
||||
>b : Symbol(x.b, Decl(file2.ts, 7, 7))
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
=== tests/cases/compiler/file1.d.ts ===
|
||||
declare module "file1" {
|
||||
function foo(): void;
|
||||
>foo : typeof
|
||||
|
||||
namespace foo {
|
||||
>foo : typeof
|
||||
|
||||
export var v: number;
|
||||
>v : number
|
||||
}
|
||||
export = foo;
|
||||
>foo : typeof foo
|
||||
}
|
||||
|
||||
|
||||
=== tests/cases/compiler/file2.ts ===
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
>x : typeof x
|
||||
|
||||
x.b = 1;
|
||||
>x.b = 1 : number
|
||||
>x.b : number
|
||||
>x : typeof x
|
||||
>b : number
|
||||
>1 : number
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
>A : A
|
||||
>a : any
|
||||
|
||||
let b: number;
|
||||
>b : number
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/file3.ts ===
|
||||
import * as x from "file1";
|
||||
>x : typeof x
|
||||
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
>a : x.A
|
||||
>x : any
|
||||
>A : x.A
|
||||
|
||||
let b = x.b;
|
||||
>b : number
|
||||
>x.b : number
|
||||
>x : typeof x
|
||||
>b : number
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
tests/cases/compiler/file2.ts(6,15): error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
tests/cases/compiler/file2.ts(7,9): error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (0 errors) ====
|
||||
|
||||
class foo {}
|
||||
namespace foo {
|
||||
export var v = 1;
|
||||
}
|
||||
export = foo;
|
||||
|
||||
==== tests/cases/compiler/file2.ts (2 errors) ====
|
||||
import x = require("./file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
~
|
||||
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
let b: number;
|
||||
~
|
||||
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/file3.ts (0 errors) ====
|
||||
import * as x from "./file1";
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
@@ -0,0 +1,49 @@
|
||||
=== tests/cases/compiler/file1.ts ===
|
||||
|
||||
class foo {}
|
||||
>foo : Symbol(, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 12), Decl(file2.ts, 1, 8))
|
||||
|
||||
namespace foo {
|
||||
>foo : Symbol(, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 12), Decl(file2.ts, 1, 8))
|
||||
|
||||
export var v = 1;
|
||||
>v : Symbol(v, Decl(file1.ts, 3, 14))
|
||||
}
|
||||
export = foo;
|
||||
>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 12))
|
||||
|
||||
=== tests/cases/compiler/file2.ts ===
|
||||
import x = require("./file1");
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 0))
|
||||
|
||||
x.b = 1;
|
||||
>x.b : Symbol(x.b, Decl(file2.ts, 6, 7))
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 0))
|
||||
>b : Symbol(x.b, Decl(file2.ts, 6, 7))
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
>A : Symbol(A, Decl(file2.ts, 4, 26))
|
||||
>a : Symbol(A.a, Decl(file2.ts, 5, 17))
|
||||
|
||||
let b: number;
|
||||
>b : Symbol(b, Decl(file2.ts, 6, 7))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/file3.ts ===
|
||||
import * as x from "./file1";
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 6))
|
||||
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
>a : Symbol(a, Decl(file3.ts, 2, 3))
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 6))
|
||||
>A : Symbol(x.A, Decl(file2.ts, 4, 26))
|
||||
|
||||
let b = x.b;
|
||||
>b : Symbol(b, Decl(file3.ts, 3, 3))
|
||||
>x.b : Symbol(x.b, Decl(file2.ts, 6, 7))
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 6))
|
||||
>b : Symbol(x.b, Decl(file2.ts, 6, 7))
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
=== tests/cases/compiler/file1.ts ===
|
||||
|
||||
class foo {}
|
||||
>foo :
|
||||
|
||||
namespace foo {
|
||||
>foo : typeof
|
||||
|
||||
export var v = 1;
|
||||
>v : number
|
||||
>1 : number
|
||||
}
|
||||
export = foo;
|
||||
>foo : foo
|
||||
|
||||
=== tests/cases/compiler/file2.ts ===
|
||||
import x = require("./file1");
|
||||
>x : typeof x
|
||||
|
||||
x.b = 1;
|
||||
>x.b = 1 : number
|
||||
>x.b : number
|
||||
>x : typeof x
|
||||
>b : number
|
||||
>1 : number
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
>A : A
|
||||
>a : any
|
||||
|
||||
let b: number;
|
||||
>b : number
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/file3.ts ===
|
||||
import * as x from "./file1";
|
||||
>x : typeof x
|
||||
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
>a : x.A
|
||||
>x : any
|
||||
>A : x.A
|
||||
|
||||
let b = x.b;
|
||||
>b : number
|
||||
>x.b : number
|
||||
>x : typeof x
|
||||
>b : number
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
tests/cases/compiler/file2.ts(7,15): error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
tests/cases/compiler/file2.ts(8,9): error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.d.ts (0 errors) ====
|
||||
|
||||
declare module "file1" {
|
||||
class foo {}
|
||||
namespace foo {
|
||||
export var v: number;
|
||||
}
|
||||
export = foo;
|
||||
}
|
||||
|
||||
|
||||
==== tests/cases/compiler/file2.ts (2 errors) ====
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
~
|
||||
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
let b: number;
|
||||
~
|
||||
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/file3.ts (0 errors) ====
|
||||
import * as x from "file1";
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
@@ -0,0 +1,53 @@
|
||||
=== tests/cases/compiler/file1.d.ts ===
|
||||
|
||||
declare module "file1" {
|
||||
class foo {}
|
||||
>foo : Symbol(, Decl(file1.d.ts, 1, 24), Decl(file1.d.ts, 2, 16), Decl(file2.ts, 2, 8))
|
||||
|
||||
namespace foo {
|
||||
>foo : Symbol(, Decl(file1.d.ts, 1, 24), Decl(file1.d.ts, 2, 16), Decl(file2.ts, 2, 8))
|
||||
|
||||
export var v: number;
|
||||
>v : Symbol(v, Decl(file1.d.ts, 4, 18))
|
||||
}
|
||||
export = foo;
|
||||
>foo : Symbol(foo, Decl(file1.d.ts, 1, 24), Decl(file1.d.ts, 2, 16))
|
||||
}
|
||||
|
||||
|
||||
=== tests/cases/compiler/file2.ts ===
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 0))
|
||||
|
||||
x.b = 1;
|
||||
>x.b : Symbol(x.b, Decl(file2.ts, 7, 7))
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 0))
|
||||
>b : Symbol(x.b, Decl(file2.ts, 7, 7))
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
>A : Symbol(A, Decl(file2.ts, 5, 24))
|
||||
>a : Symbol(A.a, Decl(file2.ts, 6, 17))
|
||||
|
||||
let b: number;
|
||||
>b : Symbol(b, Decl(file2.ts, 7, 7))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/file3.ts ===
|
||||
import * as x from "file1";
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 6))
|
||||
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
>a : Symbol(a, Decl(file3.ts, 2, 3))
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 6))
|
||||
>A : Symbol(x.A, Decl(file2.ts, 5, 24))
|
||||
|
||||
let b = x.b;
|
||||
>b : Symbol(b, Decl(file3.ts, 3, 3))
|
||||
>x.b : Symbol(x.b, Decl(file2.ts, 7, 7))
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 6))
|
||||
>b : Symbol(x.b, Decl(file2.ts, 7, 7))
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
=== tests/cases/compiler/file1.d.ts ===
|
||||
|
||||
declare module "file1" {
|
||||
class foo {}
|
||||
>foo :
|
||||
|
||||
namespace foo {
|
||||
>foo : typeof
|
||||
|
||||
export var v: number;
|
||||
>v : number
|
||||
}
|
||||
export = foo;
|
||||
>foo : foo
|
||||
}
|
||||
|
||||
|
||||
=== tests/cases/compiler/file2.ts ===
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
>x : typeof x
|
||||
|
||||
x.b = 1;
|
||||
>x.b = 1 : number
|
||||
>x.b : number
|
||||
>x : typeof x
|
||||
>b : number
|
||||
>1 : number
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
>A : A
|
||||
>a : any
|
||||
|
||||
let b: number;
|
||||
>b : number
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/file3.ts ===
|
||||
import * as x from "file1";
|
||||
>x : typeof x
|
||||
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
>a : x.A
|
||||
>x : any
|
||||
>A : x.A
|
||||
|
||||
let b = x.b;
|
||||
>b : number
|
||||
>x.b : number
|
||||
>x : typeof x
|
||||
>b : number
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/binaryIntegerLiteralError.ts(2,17): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/binaryIntegerLiteralError.ts(3,17): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/binaryIntegerLiteralError.ts(6,5): error TS2300: Duplicate identifier '0b11010'.
|
||||
tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/binaryIntegerLiteralError.ts(7,5): error TS2300: Duplicate identifier '26'.
|
||||
tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/binaryIntegerLiteralError.ts(8,5): error TS2300: Duplicate identifier '"26"'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/binaryIntegerLiteralError.ts (5 errors) ====
|
||||
==== tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/binaryIntegerLiteralError.ts (2 errors) ====
|
||||
// error
|
||||
var bin1 = 0B1102110;
|
||||
~~~~
|
||||
@@ -16,13 +13,7 @@ tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/binaryIntegerLiteralErr
|
||||
|
||||
var obj1 = {
|
||||
0b11010: "hi",
|
||||
~~~~~~~
|
||||
!!! error TS2300: Duplicate identifier '0b11010'.
|
||||
26: "Hello",
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier '26'.
|
||||
"26": "world",
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier '"26"'.
|
||||
};
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts(2,12): error TS2448: Block-scoped variable 'a' used before its declaration.
|
||||
tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts(5,12): error TS2448: Block-scoped variable 'a' used before its declaration.
|
||||
tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts(5,35): error TS7027: Unreachable code detected.
|
||||
tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts(8,7): error TS2448: Block-scoped variable 'b' used before its declaration.
|
||||
|
||||
|
||||
==== tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts (4 errors) ====
|
||||
// 1:
|
||||
for (let {[a]: a} of [{ }]) continue;
|
||||
~
|
||||
!!! error TS2448: Block-scoped variable 'a' used before its declaration.
|
||||
|
||||
// 2:
|
||||
for (let {[a]: a} = { }; false; ) continue;
|
||||
~
|
||||
!!! error TS2448: Block-scoped variable 'a' used before its declaration.
|
||||
~~~~~~~~
|
||||
!!! error TS7027: Unreachable code detected.
|
||||
|
||||
// 3:
|
||||
let {[b]: b} = { };
|
||||
~
|
||||
!!! error TS2448: Block-scoped variable 'b' used before its declaration.
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [blockScopedBindingUsedBeforeDef.ts]
|
||||
// 1:
|
||||
for (let {[a]: a} of [{ }]) continue;
|
||||
|
||||
// 2:
|
||||
for (let {[a]: a} = { }; false; ) continue;
|
||||
|
||||
// 3:
|
||||
let {[b]: b} = { };
|
||||
|
||||
//// [blockScopedBindingUsedBeforeDef.js]
|
||||
// 1:
|
||||
for (var _i = 0, _a = [{}]; _i < _a.length; _i++) {
|
||||
var _b = a, a = _a[_i][_b];
|
||||
continue;
|
||||
}
|
||||
// 2:
|
||||
for (var _c = a, a = {}[_c]; false;)
|
||||
continue;
|
||||
// 3:
|
||||
var _d = b, b = {}[_d];
|
||||
@@ -13,4 +13,5 @@ define(["require", "exports"], function (require, exports) {
|
||||
function foo() { }
|
||||
foo(); // ok
|
||||
}
|
||||
return foo;
|
||||
});
|
||||
@@ -1,12 +1,10 @@
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts(4,14): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts(11,9): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts(20,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts(20,9): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts(20,15): error TS1005: '{' expected.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts(21,5): error TS2300: Duplicate identifier 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts (6 errors) ====
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts (4 errors) ====
|
||||
// Optional parameters allow initializers only in implementation signatures
|
||||
// All the below declarations are errors
|
||||
|
||||
@@ -31,15 +29,11 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWit
|
||||
|
||||
var b = {
|
||||
foo(x = 1), // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
~~~~~
|
||||
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
||||
~
|
||||
!!! error TS1005: '{' expected.
|
||||
foo(x = 1) { }, // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
}
|
||||
|
||||
b.foo();
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
//// [capturedParametersInInitializers1.ts]
|
||||
// ok - usage is deferred
|
||||
function foo1(y = class {c = x}, x = 1) {
|
||||
new y().c;
|
||||
}
|
||||
|
||||
// ok - used in file
|
||||
function foo2(y = function(x: typeof z) {}, z = 1) {
|
||||
|
||||
}
|
||||
|
||||
// ok -used in type
|
||||
let a;
|
||||
function foo3(y = { x: <typeof z>a }, z = 1) {
|
||||
|
||||
}
|
||||
|
||||
//// [capturedParametersInInitializers1.js]
|
||||
// ok - usage is deferred
|
||||
function foo1(y, x) {
|
||||
if (y === void 0) { y = (function () {
|
||||
function class_1() {
|
||||
this.c = x;
|
||||
}
|
||||
return class_1;
|
||||
}()); }
|
||||
if (x === void 0) { x = 1; }
|
||||
new y().c;
|
||||
}
|
||||
// ok - used in file
|
||||
function foo2(y, z) {
|
||||
if (y === void 0) { y = function (x) { }; }
|
||||
if (z === void 0) { z = 1; }
|
||||
}
|
||||
// ok -used in type
|
||||
var a;
|
||||
function foo3(y, z) {
|
||||
if (y === void 0) { y = { x: a }; }
|
||||
if (z === void 0) { z = 1; }
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
=== tests/cases/compiler/capturedParametersInInitializers1.ts ===
|
||||
// ok - usage is deferred
|
||||
function foo1(y = class {c = x}, x = 1) {
|
||||
>foo1 : Symbol(foo1, Decl(capturedParametersInInitializers1.ts, 0, 0))
|
||||
>y : Symbol(y, Decl(capturedParametersInInitializers1.ts, 1, 14))
|
||||
>c : Symbol((Anonymous class).c, Decl(capturedParametersInInitializers1.ts, 1, 25))
|
||||
>x : Symbol(x, Decl(capturedParametersInInitializers1.ts, 1, 32))
|
||||
>x : Symbol(x, Decl(capturedParametersInInitializers1.ts, 1, 32))
|
||||
|
||||
new y().c;
|
||||
>new y().c : Symbol((Anonymous class).c, Decl(capturedParametersInInitializers1.ts, 1, 25))
|
||||
>y : Symbol(y, Decl(capturedParametersInInitializers1.ts, 1, 14))
|
||||
>c : Symbol((Anonymous class).c, Decl(capturedParametersInInitializers1.ts, 1, 25))
|
||||
}
|
||||
|
||||
// ok - used in file
|
||||
function foo2(y = function(x: typeof z) {}, z = 1) {
|
||||
>foo2 : Symbol(foo2, Decl(capturedParametersInInitializers1.ts, 3, 1))
|
||||
>y : Symbol(y, Decl(capturedParametersInInitializers1.ts, 6, 14))
|
||||
>x : Symbol(x, Decl(capturedParametersInInitializers1.ts, 6, 27))
|
||||
>z : Symbol(z, Decl(capturedParametersInInitializers1.ts, 6, 43))
|
||||
>z : Symbol(z, Decl(capturedParametersInInitializers1.ts, 6, 43))
|
||||
|
||||
}
|
||||
|
||||
// ok -used in type
|
||||
let a;
|
||||
>a : Symbol(a, Decl(capturedParametersInInitializers1.ts, 11, 3))
|
||||
|
||||
function foo3(y = { x: <typeof z>a }, z = 1) {
|
||||
>foo3 : Symbol(foo3, Decl(capturedParametersInInitializers1.ts, 11, 6))
|
||||
>y : Symbol(y, Decl(capturedParametersInInitializers1.ts, 12, 14))
|
||||
>x : Symbol(x, Decl(capturedParametersInInitializers1.ts, 12, 19))
|
||||
>z : Symbol(z, Decl(capturedParametersInInitializers1.ts, 12, 37))
|
||||
>a : Symbol(a, Decl(capturedParametersInInitializers1.ts, 11, 3))
|
||||
>z : Symbol(z, Decl(capturedParametersInInitializers1.ts, 12, 37))
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
=== tests/cases/compiler/capturedParametersInInitializers1.ts ===
|
||||
// ok - usage is deferred
|
||||
function foo1(y = class {c = x}, x = 1) {
|
||||
>foo1 : (y?: typeof (Anonymous class), x?: number) => void
|
||||
>y : typeof (Anonymous class)
|
||||
>class {c = x} : typeof (Anonymous class)
|
||||
>c : number
|
||||
>x : number
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
new y().c;
|
||||
>new y().c : number
|
||||
>new y() : (Anonymous class)
|
||||
>y : typeof (Anonymous class)
|
||||
>c : number
|
||||
}
|
||||
|
||||
// ok - used in file
|
||||
function foo2(y = function(x: typeof z) {}, z = 1) {
|
||||
>foo2 : (y?: (x: number) => void, z?: number) => void
|
||||
>y : (x: number) => void
|
||||
>function(x: typeof z) {} : (x: number) => void
|
||||
>x : number
|
||||
>z : number
|
||||
>z : number
|
||||
>1 : number
|
||||
|
||||
}
|
||||
|
||||
// ok -used in type
|
||||
let a;
|
||||
>a : any
|
||||
|
||||
function foo3(y = { x: <typeof z>a }, z = 1) {
|
||||
>foo3 : (y?: { x: number; }, z?: number) => void
|
||||
>y : { x: number; }
|
||||
>{ x: <typeof z>a } : { x: number; }
|
||||
>x : number
|
||||
><typeof z>a : number
|
||||
>z : number
|
||||
>a : any
|
||||
>z : number
|
||||
>1 : number
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
tests/cases/compiler/capturedParametersInInitializers2.ts(1,36): error TS2373: Initializer of parameter 'y' cannot reference identifier 'x' declared after it.
|
||||
tests/cases/compiler/capturedParametersInInitializers2.ts(4,26): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
|
||||
|
||||
==== tests/cases/compiler/capturedParametersInInitializers2.ts (2 errors) ====
|
||||
function foo(y = class {static c = x}, x = 1) {
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'y' cannot reference identifier 'x' declared after it.
|
||||
y.c
|
||||
}
|
||||
function foo2(y = class {[x] = x}, x = 1) {
|
||||
~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
//// [capturedParametersInInitializers2.ts]
|
||||
function foo(y = class {static c = x}, x = 1) {
|
||||
y.c
|
||||
}
|
||||
function foo2(y = class {[x] = x}, x = 1) {
|
||||
}
|
||||
|
||||
//// [capturedParametersInInitializers2.js]
|
||||
function foo(y, x) {
|
||||
if (y === void 0) { y = (function () {
|
||||
function class_1() {
|
||||
}
|
||||
class_1.c = x;
|
||||
return class_1;
|
||||
}()); }
|
||||
if (x === void 0) { x = 1; }
|
||||
y.c;
|
||||
}
|
||||
function foo2(y, x) {
|
||||
if (y === void 0) { y = (function () {
|
||||
function class_2() {
|
||||
this[x] = x;
|
||||
}
|
||||
return class_2;
|
||||
}()); }
|
||||
if (x === void 0) { x = 1; }
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import abstract class D {}
|
||||
|
||||
//// [classAbstractManyKeywords.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports["default"] = abstract;
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
@@ -22,6 +24,7 @@ var C = (function () {
|
||||
}
|
||||
return C;
|
||||
}());
|
||||
var abstract = ;
|
||||
var D = (function () {
|
||||
function D() {
|
||||
}
|
||||
|
||||
@@ -1,44 +1,38 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(2,12): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(6,5): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(10,15): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(14,5): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(18,13): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(22,5): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(10,15): error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(14,5): error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(18,13): error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(22,5): error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts (6 errors) ====
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts (4 errors) ====
|
||||
declare class C1 {
|
||||
public x : number;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
}
|
||||
|
||||
interface C1 {
|
||||
x : number;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
}
|
||||
|
||||
declare class C2 {
|
||||
protected x : number;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
!!! error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
}
|
||||
|
||||
interface C2 {
|
||||
x : number;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
!!! error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
}
|
||||
|
||||
declare class C3 {
|
||||
private x : number;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
!!! error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
}
|
||||
|
||||
interface C3 {
|
||||
x : number;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
!!! error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,11): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,15): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(6,9): error TS2300: Duplicate identifier 'bar'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(10,9): error TS2300: Duplicate identifier 'bar'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (4 errors) ====
|
||||
class C { foo: string; }
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
interface C { foo: string; }
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
|
||||
module M {
|
||||
class D {
|
||||
bar: string;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'bar'.
|
||||
}
|
||||
|
||||
interface D {
|
||||
bar: string;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'bar'.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
=== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts ===
|
||||
class C { foo: string; }
|
||||
>C : Symbol(C, Decl(classAndInterfaceWithSameName.ts, 0, 0), Decl(classAndInterfaceWithSameName.ts, 0, 24))
|
||||
>foo : Symbol(C.foo, Decl(classAndInterfaceWithSameName.ts, 0, 9), Decl(classAndInterfaceWithSameName.ts, 1, 13))
|
||||
|
||||
interface C { foo: string; }
|
||||
>C : Symbol(C, Decl(classAndInterfaceWithSameName.ts, 0, 0), Decl(classAndInterfaceWithSameName.ts, 0, 24))
|
||||
>foo : Symbol(C.foo, Decl(classAndInterfaceWithSameName.ts, 0, 9), Decl(classAndInterfaceWithSameName.ts, 1, 13))
|
||||
|
||||
module M {
|
||||
>M : Symbol(M, Decl(classAndInterfaceWithSameName.ts, 1, 28))
|
||||
|
||||
class D {
|
||||
>D : Symbol(D, Decl(classAndInterfaceWithSameName.ts, 3, 10), Decl(classAndInterfaceWithSameName.ts, 6, 5))
|
||||
|
||||
bar: string;
|
||||
>bar : Symbol(D.bar, Decl(classAndInterfaceWithSameName.ts, 4, 13), Decl(classAndInterfaceWithSameName.ts, 8, 17))
|
||||
}
|
||||
|
||||
interface D {
|
||||
>D : Symbol(D, Decl(classAndInterfaceWithSameName.ts, 3, 10), Decl(classAndInterfaceWithSameName.ts, 6, 5))
|
||||
|
||||
bar: string;
|
||||
>bar : Symbol(D.bar, Decl(classAndInterfaceWithSameName.ts, 4, 13), Decl(classAndInterfaceWithSameName.ts, 8, 17))
|
||||
}
|
||||
}
|
||||
Loaded 100 of 627 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user